public void Index_When_Subscriber_Has_CopperFacility_And_Should_Be_Redirected_To_CopperFacility_Page_One_XBox_Multiple_DropTerm_Not_In_The_Correct_Order() { using (ShimsContext.Create()) { const string subscriberID = "999000795553"; const string locationID = ""; const string deviceID = ""; var session = GetShimmedSession(); // Fake the HttpContext var context = new ShimHttpContext(); ShimHttpContext.CurrentGet = () => context; var mySIMPLTestContext = new SIMPLTestContext(); var expectedTDMSwitch = mySIMPLTestContext.GetFakeTDMSwitch(); var expectedGWR = mySIMPLTestContext.GetFakeGWRDto(); var expectedDSLAM = mySIMPLTestContext.GetFakeDSLAM(); const int numberOfXConnectItems = 1; var previousXConnectTerminalNames = new string[] { "TerminalAssignmentDtoXbox0{0}_PreviousTerminalNameValue" }; var currentXConnectTerminalNames = new string[] { "TerminalAssignmentDtoXbox0{0}_TerminalNameValue" }; var expectedXConnectList = mySIMPLTestContext.GetFakeListXConnect(numberOfXConnectItems, previousXConnectTerminalNames, currentXConnectTerminalNames); const int numberOfDropTermItems = 3; var previousDropTermTerminalNames = new string[] { "TerminalAssignmentDtoXbox01_TerminalNameValue", "TerminalAssignmentDtoDropTerm01_TerminalNameValue", "TerminalAssignmentDtoDropTerm02_TerminalNameValue" }; var currentDropTermTerminalNames = new string[] { "TerminalAssignmentDtoDropTerm01_TerminalNameValue", "TerminalAssignmentDtoDropTerm02_TerminalNameValue", "TerminalAssignmentDtoDropTerm03_TerminalNameValue", }; var expectedDropTermList = mySIMPLTestContext.GetFakeListDropTerm(numberOfDropTermItems, previousDropTermTerminalNames, currentDropTermTerminalNames); var expectedDropTermSequenceList = new List<List<DropTerm>> { expectedDropTermList }; var expectedFacilityAddress = mySIMPLTestContext.GetFakeFacilityAddress(); var localServicePathList = mySIMPLTestContext.GetFakeListServicePath(); var expectedServiceLocation = mySIMPLTestContext.GetFakeServiceLocation(expectedFacilityAddress, localServicePathList, subscriberID); var expectedMappedData = new CopperFacilityViewModel { Environment = "Parent_Environment", TDMSwitch = expectedTDMSwitch, GWR = expectedGWR, DSLAM = expectedDSLAM, XConnectList = expectedXConnectList, DropTermSequenceList = expectedDropTermSequenceList, ServiceLocation = expectedServiceLocation }; // When the Fake HttpContext is called, provide the fake session state ShimHttpContext.AllInstances.SessionGet = (o) => session; // Fake the CurrentSubscriber.SubId call ShimCurrentSubscriber.AllInstances.SubIdGet = (myProperty) => subscriberID; // Fake the CurrentSubscriber.SubId call ShimCurrentSubscriber.AllInstances.LocationIdGet = (myProperty) => locationID; ShimCurrentSubscriber.AllInstances.DpiRegionGet = delegate { return "CT"; }; var numberOfXBoxItems = numberOfXConnectItems; var previousXBoxTerminalNames = previousXConnectTerminalNames; var currentXBoxTerminalNames = currentXConnectTerminalNames; var fakeListTerminalAssignmentDtoForXBox = mySIMPLTestContext.GetFakeListTerminalAssignmentDtoForXBox(numberOfXBoxItems, previousXBoxTerminalNames, currentXBoxTerminalNames); var fakeListTerminalAssignmentDto = fakeListTerminalAssignmentDtoForXBox.ToList(); var fakeListTerminalAssignmentDtoForDropTerm = mySIMPLTestContext.GetFakeListTerminalAssignmentDtoForDropTerm(numberOfDropTermItems, previousDropTermTerminalNames, currentDropTermTerminalNames); // swamp all of the items in the fakeListTerminalAssignmentDtoForDropTerm var tempDropTermTerminalAssignmentDto = fakeListTerminalAssignmentDtoForDropTerm[0]; fakeListTerminalAssignmentDtoForDropTerm[0] = fakeListTerminalAssignmentDtoForDropTerm[1]; fakeListTerminalAssignmentDtoForDropTerm[1] = fakeListTerminalAssignmentDtoForDropTerm[2]; fakeListTerminalAssignmentDtoForDropTerm[2] = tempDropTermTerminalAssignmentDto; fakeListTerminalAssignmentDto.AddRange(fakeListTerminalAssignmentDtoForDropTerm); var fakePairAssignmentDto = mySIMPLTestContext.GetFakePairAssignmentDto(fakeListTerminalAssignmentDto); var fakeListPairAssignmentDto = new List<PairAssignmentDto> { fakePairAssignmentDto }; var fakeCopperPlantDataDto = mySIMPLTestContext.GetFakeCopperPlantDataDto(fakeListPairAssignmentDto); var fakePlantDataDto = new PlantDataDto { CopperPlantData = fakeCopperPlantDataDto }; var fakeServiceAddressDto = mySIMPLTestContext.GetFakeServiceAddressDto(); var fakeGetFacilitiesResponseDto = mySIMPLTestContext.GetFakeGetFacilitiesResponseDto(subscriberID, fakeServiceAddressDto, fakePlantDataDto); ShimEnterpriseClient.AllInstances.GetFacilitiesDataGetFacilitiesRequestDtoHeaderArgs = delegate { return fakeGetFacilitiesResponseDto; }; ShimCurrentSubscriber.AllInstances.FacilitiesDataGet = (myProperty) => fakeGetFacilitiesResponseDto; // Fake the FacilityViewModel.ShouldShowFiber call ShimFacilityViewModel.AllInstances.GetFacilityTypeStringString = delegate { return FacilityType.Copper; }; // A single ONT EquipmentDto myEquipmentDto1 = new EquipmentDto(); myEquipmentDto1.Type = new EquipmentTypeDto(); myEquipmentDto1.Type.ONTModel = new ONTModelDto(); myEquipmentDto1.SerialNumber = "123456"; // A single Video Device EquipmentDto myEquipmentDto2 = new EquipmentDto(); myEquipmentDto2.Type = new EquipmentTypeDto(); myEquipmentDto2.Type.ONTModel = null; myEquipmentDto2.SerialNumber = "123456"; // Build Fake fakeEquipmentDto var fakeEquipmentDto = new List<EquipmentDto>(); fakeEquipmentDto.Add(myEquipmentDto1); fakeEquipmentDto.Add(myEquipmentDto2); var fakeUserDto = new UserDto() { Email = "FakeEmail", Name = "FakeName", Role = "FakeRole" }; // Fake the RosettianClient.SearchEquipment call ShimRosettianClient.AllInstances.SearchEquipmentSearchFieldsDtoUserDto = (myRosettianClient, mySubscriberID, myUserObject) => fakeEquipmentDto; //Fake call to CurrentUser.AsUserDto() ShimCurrentUser.AsUserDto = () => fakeUserDto; // 1st Act var result = EquipmentControllerForTests.Index(subscriberID, locationID, deviceID); // 1st set of Asserts Assert.IsNotNull(result, "EquipmentController Index returned null"); Assert.IsTrue(result is PartialViewResult, "Not a PartialViewResult"); // 2nd Act var resultPartialViewResult = (PartialViewResult)result; // 2nd set of Asserts Assert.IsNotNull(resultPartialViewResult, "Cast to PartialViewResult is null"); Assert.IsNotNull(resultPartialViewResult.Model, "Model is null"); Assert.IsTrue(resultPartialViewResult.Model is CopperFacilityViewModel, "Model not CopperFacilityViewModel"); // 3rd Act var resultPartialViewResultModel = (CopperFacilityViewModel)resultPartialViewResult.Model; // 3rd set of Asserts var successCode = "200"; Assert.AreEqual(successCode, resultPartialViewResultModel.ActionResponse.Code, "Test threw an exception {0}{0}{1}", Environment.NewLine, resultPartialViewResultModel.ActionResponse.Message); // 4th Act var jss = new JavaScriptSerializer(); // 4th set of Asserts Assert.AreEqual(jss.Serialize(expectedMappedData.DropTermSequenceList), jss.Serialize(resultPartialViewResultModel.DropTermSequenceList), "DropTermSequenceList didn't match"); Assert.AreEqual(jss.Serialize(expectedMappedData.DSLAM), jss.Serialize(resultPartialViewResultModel.DSLAM), "DSLAM didn't match"); Assert.AreEqual(jss.Serialize(expectedMappedData.Environment), jss.Serialize(resultPartialViewResultModel.Environment), "Enviroment didn't match"); Assert.AreEqual(jss.Serialize(expectedMappedData.GWR), jss.Serialize(resultPartialViewResultModel.GWR), "GWR didn't match"); Assert.AreEqual(jss.Serialize(expectedMappedData.PathCount), jss.Serialize(resultPartialViewResultModel.PathCount), "PathCount didn't match"); Assert.AreEqual(jss.Serialize(expectedMappedData.ServiceLocation), jss.Serialize(resultPartialViewResultModel.ServiceLocation), "ServiceLocation didn't match"); Assert.AreEqual(jss.Serialize(expectedMappedData.TDMSwitch), jss.Serialize(resultPartialViewResultModel.TDMSwitch), "TDMSwitch didn't match"); Assert.AreEqual(jss.Serialize(expectedMappedData.XConnectList), jss.Serialize(resultPartialViewResultModel.XConnectList), "XConnectList didn't match"); } }