public void RemoveResidentialGateway_ValidateSuccessScenario()
        {
            using (ShimsContext.Create())
            {
                //Arrange
                var myContext = new SIMPLTestContext();

                //Build FakeDto
                var fakeUserDto = myContext.GetFakeUserDtoObject();

                //Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                // Fake the HttpContext
                var context = new ShimHttpContext();
                ShimHttpContext.CurrentGet = () => context;

                // Fake the session state for HttpContext
                var session = new ShimHttpSessionState
                {
                    ItemGetString = s =>
                    {
                        if (s == "")
                            return null;
                        return null;
                    }
                };

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = (o) => session;

                var fakeServiceAccount = myContext.GetFakeServiceAccountDto();
                var listFakeServiceAccounts = new List<ServiceAccountDto>
                {
                    fakeServiceAccount
                };

                //Expected result
                const string expectedBaseModelValue = "A5550";
                const string expectedSerialNumber = "PACE99999991";
                const string expectedLocationId = "locId";

                ShimCurrentSubscriber.AllInstances.PhoneServicesListGet = (o) => listFakeServiceAccounts;
                ShimCurrentSubscriber.AllInstances.ServiceAccountListGet = (myTest) => listFakeServiceAccounts;
                ShimCurrentSubscriber.AllInstances.CurrentServiceAccountGet = (myTest) => fakeServiceAccount;
                ShimCurrentSubscriber.AllInstances.SubIdGet = (o) => "89451";
                ShimCurrentSubscriber.AllInstances.LocationIdGet = (o) => expectedLocationId;

                // set WanIpAddress
                ShimCurrentSubscriber.AllInstances.WanIpAddressGet = o => "12:12:12:12";
                ShimRosettianClient.AllInstances.LoadSubscriberStringUserDto = (client, subId, userDto) => new SubscriberDto();
                ShimCurrentSubscriber.UpdateWanIpAddressString = (myWanIpAddress) => { };

                var RgType = new EquipmentTypeDto
                {
                    ONTModel = new ONTModelDto
                    {
                        BaseModel = expectedBaseModelValue
                    },
                    Category = EquipmentCategoryDto.RGDataPort
                };

                var equipmentDataDto = new EquipmentDto
                {
                    SerialNumber = expectedSerialNumber + "D01",
                    LocationId = expectedLocationId,
                    Type = RgType,
                    Status = "ACTIVE"
                };

                var equipmentPhoneDto01 = new EquipmentDto
                {
                    SerialNumber = expectedSerialNumber + "P01",
                    LocationId = expectedLocationId,
                    Type = RgType,
                    Status = "ACTIVE"
                };

                var equipmentPhoneDto02 = new EquipmentDto
                {
                    SerialNumber = expectedSerialNumber + "P02",
                    LocationId = expectedLocationId,
                    Type = RgType,
                    Status = "ACTIVE"
                };

                var searchEquipmentsResult = new List<EquipmentDto>();
                searchEquipmentsResult.Add(equipmentDataDto);
                searchEquipmentsResult.Add(equipmentPhoneDto01);
                searchEquipmentsResult.Add(equipmentPhoneDto02);

                ShimRosettianClient.AllInstances.SearchEquipmentSearchFieldsDtoUserDto =
                    (myTestClient, mySearchFields, myUserDto) => searchEquipmentsResult;

                ShimRosettianClient.AllInstances.ReturnToHeadendListOfStringUserDto = (myTestClient, mySerialNumberList, myUserDto) => true;

                var compositeEquipment = new CompositeEquipment
                {
                    ErrorDetails = new ErrorDetails()
                    {
                        Code = ResidentialGatewayErrorCode.GatewayNotFound.ToString(),
                        Message = @"Active RG not Found on Account. Provide the RG serial number and click the button below to associate."
                    }
                };
                ShimBusinessFacade.AllInstances.LoadCompositeEquipmentSearchFieldsDtoUserDto =
                    (myFacade, mySearchFields, arg3) => compositeEquipment;

                // First Act
                var residentialController = DependencyResolver.Current.GetService<ResidentialGatewayController>();
                var result = residentialController.RemoveResidentialGateway("deviceID");

                // First Assert
                Assert.IsNotNull(result, "Returned Json result with rendered partial view is null.");
                Assert.IsTrue(result is JsonResult, "result is not a JsonResult");

                // Second Act
                var resultJson = result as JsonResult;

                // Second Assert
                Assert.IsNotNull(resultJson, "Returned Json result is null.");
                dynamic resultData = resultJson.Data;
                var status = resultData.status as string;
                var errorMessage = string.Empty;
                if (status == "error")
                {
                    errorMessage = resultData.errorMessage;
                }
                Assert.AreEqual("valid", status, "RemoveResidentialGateway_HappyPath() - unexpected status from RemoveResidentialGateway() - {0}", errorMessage);
                var renderedPartial = resultData.returnedPartial as string;
                Assert.IsNotNull(renderedPartial, "Prerendered partial is null.");
            }
        }
Ejemplo n.º 2
0
        public void CVoipPhoneController_CreatePhone_With_Valid10Digit_PhoneNumber_CreateSubscriberPhone_In_Triad_Failed()
        {
            using (ShimsContext.Create())
            {
                // Fake the session state for HttpContext
                var session = new ShimHttpSessionState
                {
                    ItemGetString = s =>
                    {
                        if (s == "")
                            return null;
                        return null;
                    }
                };

                //Arrange
                var myContext = new SIMPLTestContext();

                //Build FakeDto
                var fakeUserDto = myContext.GetFakeUserDtoObject();

                //Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                // Fake the HttpContext
                var context = new ShimHttpContext();
                ShimHttpContext.CurrentGet = () => context;

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = (o) => session;

                var fakeServiceAccount = myContext.GetFakeServiceAccountDto();
                var listFakeServiceAccounts = new List<ServiceAccountDto>
                {
                    fakeServiceAccount
                };

                ShimCurrentSubscriber.AllInstances.PhoneServicesListGet = delegate { return listFakeServiceAccounts; };
                ShimCurrentSubscriber.AllInstances.ServiceAccountListGet = delegate { return listFakeServiceAccounts; };
                ShimCurrentSubscriber.AllInstances.CurrentServiceAccountGet = delegate { return fakeServiceAccount; };
                ShimCurrentSubscriber.AllInstances.SubIdGet = delegate { return "89451"; };

                var phoneList = new List<PhoneDto>
                {
                    new PhoneDto()
                    {
                        PhoneNumber = "2068945100",
                        PhoneProvSpec = new PhoneProvSpecDto
                        {
                            LocalPIC = new PICDto(),
                            LongDistancePIC = new PICDto(),
                        }
                    }
                };

                //fake the loaded phones
                ShimRosettianClient.AllInstances.CreateSubscriberPhoneStringPhoneDtoUserDto = delegate { return false; };

                // create phone controller instance
                var phoneController = DependencyResolver.Current.GetService<CVoipPhoneController>();

                // Valid 10 digit Phone Number
                var result = phoneController.CreatePhone("2068945100");

                var jsonResult = result as JsonResult;

                // 1st Assert
                Assert.IsNotNull(jsonResult, "The result was not a JsonResult");

                // 2nd Assert
                Assert.AreEqual(((dynamic)jsonResult.Data).status, "error");

                // 3rd Assert
                Assert.AreEqual(((dynamic)jsonResult.Data).code, "500");

                // 4th Assert
                Assert.IsTrue(((dynamic)jsonResult.Data).errorMessage.Contains("Error creating phone in Triad"));
            }
        }
Ejemplo n.º 3
0
        public void CVoipPhoneController_CreatePhone_With_Valid10Digit_PhoneNumber_Successful()
        {
            using (ShimsContext.Create())
            {
                // Fake the session state for HttpContext
                var session = new ShimHttpSessionState
                {
                    ItemGetString = s =>
                    {
                        if (s == "")
                            return null;
                        return null;
                    }
                };

                //Arrange
                var myContext = new SIMPLTestContext();

                //Build FakeDto
                var fakeUserDto = myContext.GetFakeUserDtoObject();

                //Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                // Fake the HttpContext
                var context = new ShimHttpContext();
                ShimHttpContext.CurrentGet = () => context;

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = (o) => session;

                var fakeServiceAccount = myContext.GetFakeServiceAccountDto();
                var listFakeServiceAccounts = new List<ServiceAccountDto>
                {
                    fakeServiceAccount
                };

                ShimCurrentSubscriber.AllInstances.PhoneServicesListGet = delegate { return listFakeServiceAccounts; };
                ShimCurrentSubscriber.AllInstances.ServiceAccountListGet = delegate { return listFakeServiceAccounts; };
                ShimCurrentSubscriber.AllInstances.CurrentServiceAccountGet = delegate { return fakeServiceAccount; };
                ShimCurrentSubscriber.SessionInstanceGet = () => new ShimCurrentSubscriber();

                var phoneList = new List<PhoneDto>
                {
                    new PhoneDto()
                    {
                        PhoneNumber = "2068945100",
                        PhoneProvSpec = new PhoneProvSpecDto
                        {
                            LocalPIC = new PICDto(),
                            LongDistancePIC = new PICDto(),
                        }
                    }
                };

                //fake the loaded phones
                ShimRosettianClient.AllInstances.CreateSubscriberPhoneStringPhoneDtoUserDto = delegate { return true; };
                ShimRosettianClient.AllInstances.LoadSubscriberPhonesStringUserDto = delegate { return phoneList; };
                ShimRosettianClient.AllInstances.UpdateSubscriberPhoneStringPhoneDtoUserDtoBoolean = delegate { return true; };

                // create phone controller instance
                var phoneController = DependencyResolver.Current.GetService<CVoipPhoneController>();

                // Valid 10 digit Phone Number
                var result = phoneController.CreatePhone("2068945100");

                // 1st Assert
                Assert.IsNotNull(result, "CVoipController CreatePhone returned null");

                var jsonResult = result as JsonResult;

                // 2nd Assert
                Assert.IsNotNull(jsonResult, "Cast to JsonResult result in null result");

                // 3rd Assert
                Assert.IsNotNull(jsonResult.Data, "jsonResult.Data is null");

                // 4th Assert
                Assert.AreEqual(((dynamic)jsonResult.Data).code, "200", "Invalid status code returned from controller");
            }
        }
Ejemplo n.º 4
0
        public void CVoipPhoneController_AddPhoneServices_Successful()
        {
            using (ShimsContext.Create())
            {
                // Fake the session state for HttpContext
                var session = new ShimHttpSessionState
                {
                    ItemGetString = s =>
                    {
                        if (s == "")
                            return null;
                        return null;
                    }
                };

                //Arrange
                var myContext = new SIMPLTestContext();

                //Build FakeDto
                var fakeUserDto = myContext.GetFakeUserDtoObject();

                //Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                // Fake the HttpContext
                var context = new ShimHttpContext();
                ShimHttpContext.CurrentGet = () => context;

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = (o) => session;

                var fakeServiceAccount = myContext.GetFakeServiceAccountDto();
                var listFakeServiceAccounts = new List<ServiceAccountDto>
                {
                    fakeServiceAccount
                };

                ShimCurrentSubscriber.AllInstances.PhoneServicesListGet = delegate { return listFakeServiceAccounts; };
                ShimCurrentSubscriber.AllInstances.ServiceAccountListGet = delegate { return listFakeServiceAccounts; };
                ShimCurrentSubscriber.AllInstances.CurrentServiceAccountGet = delegate { return fakeServiceAccount; };
                ShimCurrentSubscriber.AllInstances.SubIdGet = delegate { return "89451"; };
                ShimCurrentSubscriber.AllInstances.VoiceProductTypeGet = delegate { return SubscriberEnums.VoiceProductType.CVoip; };

                var phoneList = new List<PhoneDto>
                {
                    new PhoneDto()
                    {

                        PhoneNumber = "2068945100",
                        PhoneProvSpec = new PhoneProvSpecDto
                        {
                            LocalPIC = new PICDto(),
                            LongDistancePIC = new PICDto(),
                            DSLUnitAddress = new List<DSLUnitAddressDto>
                            {
                                new DSLUnitAddressDto() {CLLICode = "ACME", HSIPort = "01-10-10"}
                            },
                            PrimaryNumber = "2068945100",
                            Services = new ServiceCollectionDto()
                            {
                                new DAL.DataTransfer.Provisioning.ServiceDto
                                {
                                    ClassName = "U-VERSE VOIP",
                                    Description = "METASWITCH SIP",
                                    Name = "FTRCFS"
                                }
                            }
                        }
                    }
                };

                //fake the loaded phones
                ShimRosettianClient.AllInstances.LoadSubscriberPhonesStringUserDto = delegate { return phoneList; };
                ShimRosettianClient.AllInstances.UpdateSubscriberPhoneStringPhoneDtoUserDtoBoolean = delegate { return true; };

                // create phone controller instance
                var phoneController = DependencyResolver.Current.GetService<CVoipPhoneController>();

                var result = phoneController.AddServices("2068945100", "[{\"className\":\"U-VERSE VOIP\",\"name\":\"FTRCFS\",\"description\":\"METASWITCH SIP\"}]", "[{\"className\":\"U-VERSE VOIP\",\"name\":\"FTRCFS\",\"description\":\"METASWITCH SIP\"}]");

                // 1st Assert
                Assert.IsNotNull(result, "CVoipController AddServices returned null");

                var jsonResult = result as JsonResult;

                // 2nd Assert
                Assert.IsNotNull(jsonResult, "Cast to JsonResult result in null result");

                // 3rd Assert
                Assert.IsNotNull(jsonResult.Data, "jsonResult.Data is null");

                // 4th Assert
                Assert.AreEqual(((dynamic)jsonResult.Data).code, "200", "Invalid status code returned from controller");
            }
        }