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); } }