public async Task B02_Update_Asset_LastModified_DateTime_Test() { var serialNumber = "CNU0183F33"; var updateAssetStatus = EST_HWAssetStatus.Deployed; var originalModifiedDate = new DateTime(); var updatedModifiedDate = new DateTime(); var hardwareAssetService = new BAM_HardwareAssetServices(); var result = hardwareAssetService.GetHardwareAsset(serialNumber); var originalhardwareAsset = result.First(); originalModifiedDate = (DateTime)originalhardwareAsset.LastModified; var newHardwareAsset = hardwareAssetService.SetHardwareAssetStatus(originalhardwareAsset, updateAssetStatus); newHardwareAsset.LastModified = DateTime.Now; List <HardwareTemplate> hardwareAssetList = new List <HardwareTemplate>(); hardwareAssetList = hardwareAssetService.UpdateTemplate(newHardwareAsset, originalhardwareAsset); Assert.IsNotNull(hardwareAssetList, "Return list is null"); Assert.IsTrue(hardwareAssetList.Count > 1, "Return list doesn't include 2 records"); var updatedHardwareAsset = hardwareAssetService.GetHardwareAsset(serialNumber).FirstOrDefault(); Assert.IsNotNull(updatedHardwareAsset, "Updated Asset is null"); Assert.IsTrue(updatedHardwareAsset.SerialNumber == serialNumber, "SerialNumbers don't match"); updatedModifiedDate = (DateTime)updatedHardwareAsset.LastModified; Assert.IsTrue(updatedModifiedDate != originalModifiedDate, "Original and Updated LastModified Date are the same"); Assert.IsTrue(updatedModifiedDate > originalModifiedDate, "Updated LastModified Date is not greater that the Original"); }
public void E03_EstService_GetExportData_Exists_in_BAMService_Update() { var updateAssetStatus = EST_HWAssetStatus.Retired; var estService = new EST_Service(); var queryBuilder = new QueryBuilder { StartDateString = "01/01/2017", EndDateString = "30/01/2017", PageCount = 100 }; // Get Records from Esteem System var dataExport = estService.GetExportData(queryBuilder); var originalModifiedDate = new DateTime(); var updatedModifiedDate = new DateTime(); Assert.IsNotNull(dataExport, "DataExport model returned null"); Assert.IsNotNull(dataExport.DeployedToBAMUserList, "DeployedToBAMUserList model returned null"); Assert.IsTrue(dataExport.DeployedToBAMUserList.Any(), "DeployedToBAMUserList didn't return any items"); var rand = new Random(); // Select a Random record var assetList = dataExport.DeployedToBAMUserList; var asset = assetList[rand.Next(assetList.Count)]; // Get respective record from BAM Api var hardwareAssetService = new BAM_HardwareAssetServices(); var bamAssetList = hardwareAssetService.GetHardwareAsset(asset.SerialNumber); Assert.IsNotNull(bamAssetList, "BAM Asset is null"); Assert.IsTrue(bamAssetList.Count == 1, "Get BAM Asset didn't return 1 item " + bamAssetList.Count.ToString()); var bamAsset = bamAssetList.First(); Assert.IsTrue(bamAsset.SerialNumber.Contains(asset.SerialNumber), "BAM and Esteem Asset Serial Numbers do not match"); // Set the BAM record to new AssetStatus var newHardwareAsset = hardwareAssetService.SetHardwareAssetStatus(bamAsset, updateAssetStatus); // Update BAM record on BAM Api var hardwareAssetList = hardwareAssetService.UpdateTemplate(newHardwareAsset, bamAsset); Assert.IsNotNull(hardwareAssetList, "Return list is null"); Assert.IsTrue(hardwareAssetList.Count > 1, "Return list doesn't include 2 records"); // Get the newly updated BAM record var updatedHardwareAsset = hardwareAssetService.GetHardwareAsset(asset.SerialNumber).FirstOrDefault(); Assert.IsNotNull(updatedHardwareAsset, "Updated Asset is null"); Assert.IsTrue(updatedHardwareAsset.SerialNumber == asset.SerialNumber, "SerialNumbers don't match"); updatedModifiedDate = (DateTime)updatedHardwareAsset.LastModified; // Check Updates worked successfully Assert.IsTrue(updatedModifiedDate != originalModifiedDate, "Original and Updated LastModified Date are the same"); Assert.IsTrue(updatedModifiedDate > originalModifiedDate, "Updated LastModified Date is not greater that the Original"); Assert.IsTrue(hardwareAssetList[0].HardwareAssetStatus.Name == updateAssetStatus.ToBAMString(), "Updated Asset status doesn't equal BAM AssetStatus Enum"); }
public void E02_EstService_GetExportData_Exists_in_BAMService_Random() { var estService = new EST_Service(); var queryBuilder = new QueryBuilder { StartDateString = "01/01/2017", EndDateString = "30/01/2017", PageCount = 100 }; var dataExport = estService.GetExportData(queryBuilder); Assert.IsNotNull(dataExport, "DataExport model returned null"); Assert.IsNotNull(dataExport.DeployedToBAMUserList, "DeployedToBAMUserList model returned null"); Assert.IsTrue(dataExport.DeployedToBAMUserList.Any(), "DeployedToBAMUserList didn't return any items"); var rand = new Random(); var assetList = dataExport.DeployedToBAMUserList; var asset = assetList[rand.Next(assetList.Count)]; var hardwareAssetService = new BAM_HardwareAssetServices(); var bamAssetList = hardwareAssetService.GetHardwareAsset(asset.SerialNumber); Assert.IsNotNull(bamAssetList, "BAM Asset is null"); Assert.IsTrue(bamAssetList.Count == 1, "Get BAM Asset didn't return 1 item " + bamAssetList.Count.ToString()); var bamAsset = bamAssetList.First(); Assert.IsTrue(bamAsset.SerialNumber.Contains(asset.SerialNumber), "BAM and Esteem Asset Serial Numbers do not match"); }
public async Task B03_Update_Basic() { var serialNumber = "CNU0183F33"; Guid.TryParse("acdcedb7-100c-8c91-d664-4629a218bd94", out var objectStatusId); var updateAssetStatus = EST_HWAssetStatus.Retired; var originalModifiedDate = new DateTime(); var updatedModifiedDate = new DateTime(); var hardwareAssetService = new BAM_HardwareAssetServices(); var result = hardwareAssetService.GetHardwareAsset(serialNumber); var originalhardwareAsset = result.First(); originalModifiedDate = (DateTime)originalhardwareAsset.LastModified; var newHardwareAsset = CloneObject.Clone(originalhardwareAsset); // hardwareAssetService.SetHardwareAssetStatus(originalhardwareAsset, updateAssetStatus); newHardwareAsset.AssetTag = "Hugh Test"; //newHardwareAsset.BaseId = null; //newHardwareAsset.TimeAdded = newHardwareAsset.ObjectStatus = new ObjectStatus() { Id = objectStatusId.ToString() }; //newHardwareAsset.LastModified = DateTime.Now; List <HardwareTemplate> hardwareAssetList = new List <HardwareTemplate>(); hardwareAssetList = hardwareAssetService.UpdateTemplate(newHardwareAsset, originalhardwareAsset); Assert.IsNotNull(hardwareAssetList, "Return list is null"); Assert.IsTrue(hardwareAssetList.Count > 1, "Return list doesn't include 2 records"); var updatedHardwareAsset = hardwareAssetService.GetHardwareAsset(serialNumber).FirstOrDefault(); Assert.IsNotNull(updatedHardwareAsset, "Updated Asset is null"); Assert.IsTrue(updatedHardwareAsset.SerialNumber == serialNumber, "SerialNumbers don't match"); updatedModifiedDate = (DateTime)updatedHardwareAsset.LastModified; Assert.IsTrue(updatedModifiedDate != originalModifiedDate, "Original and Updated LastModified Date are the same"); Assert.IsTrue(updatedModifiedDate > originalModifiedDate, "Updated LastModified Date is not greater that the Original"); }
public async Task B04_GetAssetItem_Test() { var hardwareAssetTemplateId = "c0c58e7f-7865-55cc-4600-753305b9be64"; var serialNumber = "CNU0183F33"; // "BAM -L-00"; //0852 var serialNumberFull = "CND7506PT8"; // "BAM -L-00"; //0852 var hardwareAssetService = new BAM_HardwareAssetServices(); var result = hardwareAssetService.GetHardwareAsset(serialNumber); Assert.IsNotNull(result, "Result didn't deserialize to BAM_HardwareTemplate_Full"); Assert.IsTrue(result.Any(), "Result didn't any results"); Assert.IsTrue(result.First().SerialNumber == serialNumber, "SerialNumbers don't match"); }
public async Task B00_GetAssetItem_SetHardwareStatus_Test() { var hardwareAssetTemplateId = "c0c58e7f-7865-55cc-4600-753305b9be64"; var serialNumber = "CNU0183F33"; // "BAM -L-00"; //0852 var serialNumberFull = "CND7506PT8"; // "BAM -L-00"; //0852 var hardwareAssetService = new BAM_HardwareAssetServices(); var result = hardwareAssetService.GetHardwareAsset(serialNumber); Assert.IsNotNull(result, "Result didn't deserialize to BAM_HardwareTemplate_Full"); Assert.IsTrue(result.Any(), "Result didn't any results"); Assert.IsTrue(result.First().SerialNumber == serialNumber, "SerialNumbers don't match"); var hardwareAsset = result.First(); var newHardwareAsset = hardwareAssetService.SetHardwareAssetStatus(hardwareAsset, EST_HWAssetStatus.Deployed); Assert.IsNotNull(newHardwareAsset, "Updated Hardware Asset returned null"); Assert.IsFalse(newHardwareAsset.Equals(hardwareAsset)); Assert.IsTrue(newHardwareAsset.HardwareAssetStatus.Name != hardwareAsset.HardwareAssetStatus.Name); Assert.IsTrue(newHardwareAsset.HardwareAssetStatus.Name == "Deployed"); }
public void E01_EstService_GetExportData_Exists_in_BAMService() { var estService = new EST_Service(); var queryBuilder = new QueryBuilder(); var dataExport = estService.GetExportData(null); Assert.IsNotNull(dataExport, "DataExport model returned null"); Assert.IsNotNull(dataExport.DeployedToBAMUserList, "DeployedToBAMUserList model returned null"); Assert.IsTrue(dataExport.DeployedToBAMUserList.Any(), "DeployedToBAMUserList didn't return any items"); var asset = dataExport.DeployedToBAMUserList.First(); var hardwareAssetService = new BAM_HardwareAssetServices(); var bamAssetList = hardwareAssetService.GetHardwareAsset(asset.SerialNumber); Assert.IsNotNull(bamAssetList, "BAM Asset is null"); Assert.IsTrue(bamAssetList.Count == 1, "Get BAM Asset didn't return 1 item " + bamAssetList.Count.ToString()); var bamAsset = bamAssetList.First(); Assert.IsTrue(bamAsset.SerialNumber.Contains(asset.SerialNumber), "BAM and Esteem Asset Serial Numbers do not match"); }
public async Task B01_GetAssetItem_SetHardwareStatus_and_Update_FullAssertTest() { var serialNumber = "CNU0183F33"; var updateAssetStatus = EST_HWAssetStatus.Retired; var hardwareAssetService = new BAM_HardwareAssetServices(); var result = hardwareAssetService.GetHardwareAsset(serialNumber); Assert.IsNotNull(result, "Result didn't deserialize to BAM_HardwareTemplate_Full"); Assert.IsTrue(result.Any(), "Result didn't any results"); Assert.IsTrue(result.First().SerialNumber == serialNumber, "SerialNumbers don't match"); var originalhardwareAsset = result.First(); var newHardwareAsset = hardwareAssetService.SetHardwareAssetStatus(originalhardwareAsset, updateAssetStatus); Assert.IsNotNull(newHardwareAsset, "Updated Hardware Asset returned null"); Assert.IsFalse(newHardwareAsset.Equals(originalhardwareAsset), "Clone object didn't work"); Assert.IsTrue(newHardwareAsset.HardwareAssetStatus.Name != originalhardwareAsset.HardwareAssetStatus.Name, "Pre-Update Asset status didn't change"); Assert.IsTrue(newHardwareAsset.HardwareAssetStatus.Name == updateAssetStatus.ToBAMString(), "Pre-Update Asset status doesn't equal BAM AssetStatus Enum"); List <HardwareTemplate> hardwareAssetList = new List <HardwareTemplate>(); try { hardwareAssetList = hardwareAssetService.UpdateTemplate(newHardwareAsset, originalhardwareAsset); } catch (Exception exp) { hardwareAssetList = null; Assert.IsNull(exp, exp.Message); } Assert.IsNotNull(hardwareAssetList, "Return list is null"); Assert.IsTrue(hardwareAssetList.Count > 1, "Return list doesn't include 2 records"); Assert.IsTrue(hardwareAssetList[0].HardwareAssetStatus.Name != hardwareAssetList[1].HardwareAssetStatus.Name, "Original and Updated Hardware Assets Status is the same"); Assert.IsTrue(hardwareAssetList[0].HardwareAssetStatus.Name == updateAssetStatus.ToBAMString(), "Updated Asset status doesn't equal BAM AssetStatus Enum"); }
public async Task B01_InsertNewAsset() { var originalModifiedDate = new DateTime(); var updatedModifiedDate = new DateTime(); var asset = new BAM_Asset() { Manufacturer = "Hewlet-Packard", Model = "HP ELITEBOOK 840G3", SerialNumber = "5CG749386E", AssetName = "BAM-L-005289", DisplayName = "HP ELITEBOOK 840G3 - Test", RequestUser = "******", HWAssetStatus = EST_HWAssetStatus.NewItem }; // Get User IBAM_UserService userService = new BAM_UserService(_bamClient); var user = userService.GetUser(asset.RequestUser); Assert.IsNotNull(user, "User item is null"); Assert.IsTrue(user.Name == asset.RequestUser, "user record is not the same"); // Get AssetStatus IBAM_AssetStatusService assetStatusService = new BAM_AssetStatusService(_bamClient); var assetStatus = assetStatusService.GetAssetStatusTemplate(asset.HWAssetStatus); Assert.IsNotNull(assetStatus, "assetStatus item is null"); Assert.IsTrue(assetStatus.Name == asset.HWAssetStatus.ToDescriptionString(), "assetStatus record is not the same"); Guid.TryParse("c0c58e7f-7865-55cc-4600-753305b9be64", out var classTypeId); Guid.TryParse("e728d3d3-3104-47e3-b760-9b9863ebbd9a", out var baseId); Guid.TryParse("b4a14ffd-52c8-064f-c936-67616c245b35", out var hardwareAssetTypeId); Guid.TryParse("acdcedb7-100c-8c91-d664-4629a218bd94", out var objectStatusId); // Get Projection Template var hardwareTemplate = new Models.BAM.HardwareTemplate() { LastModified = new DateTime(0001, 01, 01, 00, 00, 00), //LastModifiedBy = null, TimeAdded = new DateTime(0001, 01, 01, 00, 00, 00), ClassTypeId = classTypeId.ToString(), BaseId = null, // baseId.ToString(), //ClassName = "Cireson.AssetManagement.HardwareAsset", //FullClassName = "Hardware Asset", Manufacturer = asset.Manufacturer, Model = asset.Model, SerialNumber = asset.SerialNumber, AssetTag = asset.AssetName, DisplayName = asset.DisplayName, HardwareAssetStatus = assetStatusService.GetAssetStatusTemplate(asset.HWAssetStatus), Description = "Hugh Testing", HardwareAssetType = new HardwareAssetType() { Id = hardwareAssetTypeId.ToString(), //Name = "Computer" }, HardwareAssetID = Guid.NewGuid().ToString(), ObjectStatus = new ObjectStatus() { Id = objectStatusId.ToString() } //Target_HardwareAssetHasCostCenter = new TargetHardwareAssetHasCostCenter() //{ // Id = "128bdb2d-f5bd-f8b6-440e-e3f7d8ab4858", // DisplayName = "BBN.014A" //}, //Target_HardwareAssetHasLocation = new TargetHardwareAssetHasLocation() //{ // Id = "b1ae24b1-f520-4960-55a2-62029b1ea3f0", // DisplayName = "Esteem" //}, //Target_HardwareAssetHasPrimaryUser = new TargetHardwareAssetHasPrimaryUser() //{ // ClassTypeId = user.Id, // FullName = user.Name, //} }; var hardwareAssetService = new BAM_HardwareAssetServices(_bamClient); var returnItems = hardwareAssetService.InsertTemplate(hardwareTemplate).FirstOrDefault(); Assert.IsNotNull(returnItems, "Updated Asset is null"); Assert.IsTrue(returnItems.SerialNumber == hardwareTemplate.SerialNumber, "SerialNumbers don't match"); var updatedHardwareAsset = hardwareAssetService.GetHardwareAsset(hardwareTemplate.SerialNumber).FirstOrDefault(); Assert.IsNotNull(updatedHardwareAsset, "Updated Asset is null"); Assert.IsTrue(updatedHardwareAsset.SerialNumber == hardwareTemplate.SerialNumber, "SerialNumbers don't match"); updatedModifiedDate = (DateTime)updatedHardwareAsset.LastModified; Assert.IsTrue(updatedModifiedDate != originalModifiedDate, "Original and Updated LastModified Date are the same"); Assert.IsTrue(updatedModifiedDate > originalModifiedDate, "Updated LastModified Date is not greater that the Original"); }