public void SvcController_EditBlockedServices_allBlocked() { //Data initialization var sub = Data.Data.Simplcpe1(); var dev = sub.Accounts[0].Equipment.FirstOrDefault(); PartialViewResult result = null; if (dev != null) { dev.BlockedServiceList = sub.Accounts[0].Services; using (var client = new RosettianClient()) { client.UpdateEquipment(dev, _user); } //Click Edit for Blocked Services var expectedSvcAsJSON = ServicesControllerHelper.ConvertServicesToJSON(dev.BlockedServiceList); result = _serviceController.EditBlockedServices(expectedSvcAsJSON, sub.ID, dev.SerialNumber, "") as PartialViewResult; } ServicesModel actualSvcModel = null; if (result != null) { Common.Validation.Validate("BlockedServicesWindow", result.ViewName, "ViewName"); actualSvcModel = result.Model as ServicesModel; } if (dev != null) if (actualSvcModel != null) Assert.AreEqual((object) dev.SerialNumber, actualSvcModel.DeviceID); if (actualSvcModel != null) { Assert.AreEqual(sub.ID, actualSvcModel.SubscriberID); //Validate the services Common.Validation.ValidateService(sub.Accounts[0].Services, ServicesControllerHelper.ConvertJSONToServices(actualSvcModel.ServicesAsJSON), TestAttribute.Service); //Validate Unblocked Subscriber Services is empty Assert.AreEqual(0, actualSvcModel.SubscriberServicesList.Count); //Validate Blocked Services displayed matches the actual blocked services ValidateBlockedServices(dev.BlockedServiceList, actualSvcModel.BlockedServicesList); } }
public void EditBlockedServicesMethod_SomeBlocked() { // Arrange PartialViewResult resultEditBlockedServices = null; string expectedServicesAsJSON = null; ServicesModel actualServicesModel = null; List<ServiceDto> expectedServiceList = null; ServiceCollectionDto actualServices = null; SubscriberDto expectedSubscriber = SIMPL.Test.IntegrationTest.Data.Data.GetSIMPLSubscriber04CPE01(); Assert.IsNotNull(expectedSubscriber, "subscriber"); Assert.IsNotNull(expectedSubscriber.ID, "subscriber.ID"); EquipmentCollectionDto ec = new EquipmentCollectionDto(); ec.Add(new EquipmentDto()); ec[0].AssociatedSubscriberId = expectedSubscriber.ID; ec[0].BlockedServiceList.Add(new ServiceDto()); ec[0].BlockedServiceList[0] = new ServiceDto { ClassName = ServiceClassType.ProvisionedOntDataPort.GetStringValue(), Name = "ENET", Description = "RJ-45 ETHERNET PORT" }; expectedSubscriber.Accounts[0].Equipment = new EquipmentCollectionDto(); expectedSubscriber.Accounts[0].Equipment.Add(ec[0]); EquipmentDto expectedDevice = expectedSubscriber.Accounts[0].Equipment.FirstOrDefault(); Assert.IsNotNull(expectedDevice, "expectedDevice"); expectedDevice.BlockedServiceList = new ServiceCollectionDto(); expectedDevice.BlockedServiceList.AddRange(expectedSubscriber.Accounts[0].Services.GetRange(0, 2)); using (RosettianClient client = new RosettianClient()) { client.UpdateEquipment(expectedDevice, RosettianUser); } expectedServicesAsJSON = ServicesControllerHelper.ConvertServicesToJSON(expectedDevice.BlockedServiceList); Assert.IsNotNull(expectedServicesAsJSON, "expectedServicesAsJSON"); // Act resultEditBlockedServices = ServicesControllerForTests.EditBlockedServices(expectedServicesAsJSON, expectedSubscriber.ID, expectedDevice.SerialNumber, "") as PartialViewResult; // Assert - First group Assert.IsNotNull(resultEditBlockedServices, "resultEditBlockedServices"); // Arrange/Act - Second group actualServicesModel = resultEditBlockedServices.Model as ServicesModel; // Assert - Second group Assert.IsNotNull(actualServicesModel, "actualServicesModel"); Assert.IsNull(actualServicesModel.ServicesActionResult, "ServicesActionResult is not null"); Assert.AreEqual(expectedSubscriber.ID, actualServicesModel.SubscriberID, "Subscriber.ID compared to SubscriberID"); Assert.AreEqual(3, actualServicesModel.SubscriberServicesList.Count, "actualServicesModel.SubscriberServicesList.Count"); // Arrange/Act - Third group expectedServiceList = expectedSubscriber.Accounts[0].Services.OrderBy(x => x.Name).ToList(); actualServices = ServicesControllerHelper.ConvertJSONToServices(actualServicesModel.ServicesAsJSON); // Assert - Third group int i = 0; foreach (ServiceDto individualService in actualServices) { Assert.AreEqual(expectedServiceList[i].Name, individualService.Name, "Service Name - index count {0}", i); Assert.AreEqual(expectedServiceList[i].Description, individualService.Description, "Service Description - index count {0}", i); Assert.AreEqual(expectedServiceList[i].ClassName, individualService.ClassName, "Service ClassName - index count {0}", i); i++; } // Assert - Third group (continued) string message = string.Empty; // Validate Blocked Services displayed matches the actualViewModel blocked services bool resultOfValidation = this.ValidateBlockedServices(expectedDevice.BlockedServiceList, actualServicesModel.BlockedServicesList, out message); Assert.IsTrue(resultOfValidation, message); }
public void EditBlockedServicesMethod_AllBlocked() { { // Arrange PartialViewResult resultEditBlockedServices = null; //string expectedServicesAsJSON = null; const string ExpectedViewName = "EditBlockedServices_Partial"; ServicesModel actualServicesModel = null; List<ServiceDto> expectedServiceList = null; ServiceCollectionDto actualServices = null; SubscriberDto expectedSubscriber = SIMPL.Test.IntegrationTest.Data.Data.GetSIMPLSubscriber04CPE01(); Assert.IsNotNull(expectedSubscriber, "subscriber"); Assert.IsNotNull(expectedSubscriber.ID, "subscriber.ID"); // ** Subscriber.Account.Equipment has been removed EquipmentDto expectedDevice = expectedSubscriber.Accounts[0].Equipment.FirstOrDefault(); Assert.IsNotNull(expectedDevice, "expectedDevice"); expectedDevice.BlockedServiceList = expectedSubscriber.Accounts[0].Services; Assert.IsNotNull(expectedDevice.BlockedServiceList, "expectedDevice.BlockedServiceList is null"); Assert.AreNotEqual(0, expectedDevice.BlockedServiceList.Count, "expectedDevice.BlockedServiceList.Count is zero"); using (var client = new RosettianClient()) { client.UpdateEquipment(expectedDevice, RosettianUser); } var expectedServicesAsJSON = ServicesControllerHelper.ConvertServicesToJSON(expectedDevice.BlockedServiceList); // Act resultEditBlockedServices = ServicesControllerForTests.EditBlockedServices(expectedServicesAsJSON, expectedSubscriber.ID, expectedDevice.SerialNumber, "") as PartialViewResult; // Assert - First group Assert.IsNotNull(resultEditBlockedServices, "resultEditBlockedServices"); // ToDo: Need one test to verify that the ViewName is what we expect; don't need to repeat it across all of these tests. Assert.AreEqual(ExpectedViewName, resultEditBlockedServices.ViewName, "ViewName"); // Arrange/Act - Second group actualServicesModel = resultEditBlockedServices.Model as ServicesModel; // Assert - Second group Assert.IsNotNull(actualServicesModel, "actualServicesModel"); Assert.IsNull(actualServicesModel.ServicesActionResult, "ServicesActionResult is not null"); //Assert.AreEqual(expectedDevice.SerialNumber, actualServicesModel.DeviceID, "Device.SerialNumber compared to DeviceID"); Assert.AreEqual(expectedSubscriber.ID, actualServicesModel.SubscriberID, "Subscriber.ID compared to SubscriberID"); Assert.AreEqual(0, actualServicesModel.SubscriberServicesList.Count, "actualServicesModel.SubscriberServicesList.Count"); // Arrange/Act - Third group expectedServiceList = expectedSubscriber.Accounts[0].Services.OrderBy(x => x.Name).ToList(); actualServices = ServicesControllerHelper.ConvertJSONToServices(actualServicesModel.ServicesAsJSON); // Assert - Third group int i = 0; foreach (ServiceDto individualService in actualServices) { Assert.AreEqual(expectedServiceList[i].Name, individualService.Name, "Service Name - index count {0}", i); Assert.AreEqual(expectedServiceList[i].Description, individualService.Description, "Service Description - index count {0}", i); Assert.AreEqual(expectedServiceList[i].ClassName, individualService.ClassName, "Service ClassName - index count {0}", i); i++; } //Assert - Third group (continued) string message = string.Empty; //Validate Blocked Services displayed matches the actualViewModel blocked services bool resultOfValidation = this.ValidateBlockedServices(expectedDevice.BlockedServiceList, actualServicesModel.BlockedServicesList, out message); Assert.IsTrue(resultOfValidation, message); } }
public void SvcController_SaveBlockedServices_Remove() { //Data initialization var sub = Data.Data.Simplcpe1(); var dev = sub.Accounts[0].Equipment.First(); dev.BlockedServiceList = sub.Accounts[0].Services; using (var client = new RosettianClient()) { client.UpdateEquipment(dev, _user); } //Save Blocked Services dev.BlockedServiceList = new ServiceCollection(); var expectedSvcAsJSON = ServicesControllerHelper.ConvertServicesToJSON(dev.BlockedServiceList); var result = _serviceController.SaveBlockedServices(expectedSvcAsJSON, sub.ID, dev.SerialNumber) as PartialViewResult; Debug.Assert(result != null, "result != null"); Common.Validation.Validate("BlockedServices_Partial", result.ViewName, "ViewName"); var actualSvcModel = result.Model as ServicesModel; Debug.Assert(actualSvcModel != null, "actualSvcModel != null"); Assert.AreEqual(dev.SerialNumber, actualSvcModel.DeviceID); Assert.AreEqual(sub.ID, actualSvcModel.SubscriberID); var actualBlockedSvc = ServicesControllerHelper.ConvertJSONToServices(actualSvcModel.BlockedServicesAsJSON); Assert.AreEqual(0, actualBlockedSvc.Count()); //Validate blocked svcs actually updated using (var client = new RosettianClient()) { var actualEquip = client.LoadEquipment(dev.SerialNumber, true, _user); Assert.IsTrue(actualEquip.BlockedServiceList == null || !actualEquip.BlockedServiceList.Any()); } }
public void SvcController_SaveBlockedServices() { //Data initialization var sub = Data.Data.Simplcpe1(); var dev = sub.Accounts[0].Equipment.First(); dev.BlockedServiceList = sub.Accounts[0].Services; using (var client = new RosettianClient()) { client.UpdateEquipment(dev, _user); } //Save Blocked Services dev.BlockedServiceList = new ServiceCollection(); dev.BlockedServiceList.AddRange(sub.Accounts[0].Services.GetRange(0, 2)); var expectedSvcAsJSON = ServicesControllerHelper.ConvertServicesToJSON(dev.BlockedServiceList); var result = _serviceController.SaveBlockedServices(expectedSvcAsJSON, sub.ID, dev.SerialNumber) as PartialViewResult; ServicesModel actualSvcModel = null; if (result != null) { Common.Validation.Validate("BlockedServices_Partial", result.ViewName, "ViewName"); actualSvcModel = result.Model as ServicesModel; } ServiceCollection actualBlockedSvc = null; if (actualSvcModel != null) { Assert.AreEqual(dev.SerialNumber, actualSvcModel.DeviceID); Assert.AreEqual(sub.ID, actualSvcModel.SubscriberID); //Validate blocked svcs actualBlockedSvc = ServicesControllerHelper.ConvertJSONToServices(actualSvcModel.BlockedServicesAsJSON); } Common.Validation.ValidateService(dev.BlockedServiceList.ToList(), actualBlockedSvc, TestAttribute.BlockedServiceList); //Validate blocked svcs actually updated using (var client = new RosettianClient()) { var actualEquip = client.LoadEquipment(dev.SerialNumber, true, _user); Common.Validation.ValidateEquipment(dev, actualEquip); } }
public void SvcController_InitializeBlockedServices() { var sub = Data.Data.Simplcpe1(); var dev = sub.Accounts[0].Equipment.FirstOrDefault(); PartialViewResult result = null; if (dev != null) { dev.BlockedServiceList = sub.Accounts[0].Services; using (var client = new RosettianClient()) { client.UpdateEquipment(dev, _user); } result = _serviceController.InitializeBlockedServices(dev.BlockedServiceList, sub.ID, dev.SerialNumber) as PartialViewResult; } ServicesModel actualSvcModel = null; if (result != null) { Common.Validation.Validate("BlockedServices_Partial", result.ViewName, "ViewName"); actualSvcModel = result.Model as ServicesModel; } Assert.IsTrue(actualSvcModel != null && actualSvcModel.ServicesActionResult.Success); Assert.IsTrue(string.IsNullOrEmpty(actualSvcModel.ServicesActionResult.ErrorMessage) && string.IsNullOrEmpty(actualSvcModel.ServicesActionResult.Result)); Assert.AreEqual((object) dev.SerialNumber, actualSvcModel.DeviceID); Assert.AreEqual(sub.ID, actualSvcModel.SubscriberID); var actualBlockedSvc = ServicesControllerHelper.ConvertJSONToServices(actualSvcModel.BlockedServicesAsJSON); Common.Validation.ValidateService(dev.BlockedServiceList.ToList(), actualBlockedSvc, TestAttribute.BlockedServiceList); }
/// <summary> /// RestoreEquip - returns EquipmentDto - calls either Rosettian CreateEquipment or UpdateEquipment /// </summary> /// <param name="equip"></param> /// <returns></returns> protected static EquipmentDto RestoreEquip(EquipmentDto equip) { using (var client = new RosettianClient()) { if (!client.EquipmentExists(equip.SerialNumber, user)) { client.CreateEquipment(equip, user); } else { client.UpdateEquipment(equip, user); } return equip; } }
/// <summary> /// RestoreEquip - returns EquipmentCollectionDto - calls Rosettian UpdateEquipment method to reset data /// </summary> /// <param name="criteria"></param> /// <returns></returns> protected static EquipmentCollectionDto RestoreEquip(EquipmentCriteriaDto criteria) { using (var client = new RosettianClient()) { if (!client.ONTExists(criteria.SerialNumber, user)) { client.CreateONT(criteria, user); } var equipList = client.SearchEquipment(new SearchFieldsDto {EquipmentId = criteria.SerialNumber}, user) .Where(x => x.SerialNumber.Substring(0, x.SerialNumber.Length - 3) == criteria.SerialNumber).ToList(); foreach (var equip in equipList.Where(x => x.LocationId != criteria.LocationId || x.Status != criteria.Status || x.UnitAddress != criteria.UnitAddress)) { equip.LocationId = criteria.LocationId; equip.Status = criteria.Status; equip.UnitAddress = criteria.UnitAddress; client.UpdateEquipment(equip, user); } return new EquipmentCollectionDto(equipList); } }