-- Copyright (c) 2026 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
--
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.
local lu = require 'luaunit'
local bluefield_obj = require 'dpu_service.bluefield_object'
TestBluefieldCard = {}

local PCIECARD_INTF<const> = 'bmc.kepler.Systems.PCIeDevices.PCIeCard'
local DPUCARD_INTF<const> = 'bmc.kepler.Systems.DPUCard'

function TestBluefieldCard:test_add_bluefied_object()
    local obj = {
        [PCIECARD_INTF] = {
            property_changed = {
                on = function(_, cb)
                    cb('SlotID', _)
                end
            },
            SlotID = 1,
            Name = 'BlueField-3',
            SerialNumber = '111  ',
            PartNumber = '222  ',
            Model = 'BF3'
        },
        [DPUCARD_INTF] = {
            Model = ''
        }
    }
    local bf_obj = bluefield_obj.new(obj)
    bf_obj:start()
    bf_obj:stop()
    lu.assertEquals(bf_obj.dpucard.Model, 'BF3')
    lu.assertEquals(bf_obj.pciecard.PartNumber, '222')
end