public void User_tries_to_create_a_new_ONT_and_receives_a_Rosettian_error()
        {
            using (ShimsContext.Create())
            {
                //Arrange
                // Given a user that has permission to create new ont
                ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject();
                ShimCurrentUser.GetInstance = () => new ShimCurrentUser
                {
                    UserEntityGet = () => new Entity { Email = "*****@*****.**" }
                };

                // And the new ont to be created has all valid info
                var createOntModel = new CreateOntModel
                {
                    SerialNumber = "12345678",
                    LocationId = "HEADEND 04 INVENTORY",
                    Status = "IGNORE",
                    SelectedOntModel = "ONT1000M",
                    IsResidentialGateway = false,
                    Manufacturer = "Motorola"
                };

                // When creating new ont with the valid ont info
                ShimRosettianClient.AllInstances.CreateONTEquipmentCriteriaDtoUserDto =
                    (myTestClient, myEquipmentCriteria, myUserDto) => { };

                //This is for creating a Fault exception
                const string expectedErrorMessage = "This is a fault exception message";
                var faultDetail = new ValidationDetailDto()
                {
                    Message = expectedErrorMessage
                };

                var faultDetails = new List<ValidationDetailDto>();
                faultDetails.Add(faultDetail);

                var validationFault = new ValidationFaultDto()
                {
                    Details = faultDetails
                };

                var fault = new FaultException<ValidationFaultDto>(validationFault);

                //Have Controller CreateONT method throw the fault when called
                ShimRosettianClient.AllInstances.CreateONTEquipmentCriteriaDtoUserDto = delegate { throw fault; };

                //Add
                var searchController = DependencyResolver.Current.GetService<SearchController>();
                var actionResponse = searchController.CreateONT(createOntModel) as JsonResult;

                //Assert
                // Then the user receives a response
                Assert.IsNotNull(actionResponse, "CreateONT method returned null");

                // And the response is successful
                // And the ont serial number created matches the requested ont serial and manufacturer
                Assert.IsNotNull(actionResponse.Data, "CreateONT response data is null");
                var jss = new JavaScriptSerializer();
                var expectedResult = new
                {
                    status = "error",
                    errorMessage = "This is a fault exception message"
                }.ToJSON();
                Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResponse.Data.ToJSON()));
            }
        }
        public void User_Attempts_To_create_a_new_subscriber_with_correct_data_and_an_error_is_returned()
        {
            using (ShimsContext.Create())
            {
                //Arrange

                // Given a user that has permission to create new subscriber
                ShimCurrentUser.AsUserDto = new SIMPLTestContext().GetFakeUserDtoObject;

                //And good data is used in the model
                var createSubModel = new CreateSubscriberModel
                {
                    USI = "subid",
                    Name = "subname",
                    AccountType = AccountTypeDto.Residential,
                    ServiceEnabled = false,
                    CBR = "4250010001",
                    Email = "*****@*****.**",
                    PIN = "subpin",
                    PPVCap = "150.00",
                    PPVResetDay = "15",
                    PPVPrivilege = SubscriberEnums.PPVPrivilegeEnum.Capped
                };

                var searchController = DependencyResolver.Current.GetService<SearchController>();

                //This is for creating a Fault exception
                const string expectedErrorMessage = "This is a fault exception message";
                var faultDetail = new ValidationDetailDto()
                {
                    Message = expectedErrorMessage
                };

                var faultDetails = new List<ValidationDetailDto>();
                faultDetails.Add(faultDetail);

                var validationFault = new ValidationFaultDto()
                {
                    Details = faultDetails
                };

                var fault = new FaultException<ValidationFaultDto>(validationFault);

                //Have Controller CreateSubscriber method throw the fault when called
                ShimRosettianClient.AllInstances.CreateSubscriberSubscriberDtoUserDto = delegate { throw fault; };

                //Act

                //Call the actual controller method
                var actionResponse = searchController.CreateSubscriber(createSubModel) as JsonResult;

                //Assert

                // Then the user receives a response
                Assert.IsNotNull(actionResponse, "CreateSubscriber json result is null");
                Assert.IsNotNull(actionResponse.Data, "CreateSubscriber json result data is null");

                // And the expected response is a Fault exception
                var jss = new JavaScriptSerializer();
                var expectedResult = new
                {
                    status = "error",
                    isModal = false,
                    errorMessage = "This is a fault exception message"
                }.ToJSON();
                Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResponse.Data.ToJSON()));
            }
        }
        public void User_attempts_to_create_new_equipment_with_correct_data_and_a_Rosettian_error_is_returned()
        {
            using (ShimsContext.Create())
            {
                //Arrange
                // Given a user that has permission to create new equpment
                ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject();

                // And the new equipemnt to be created is a video access point
                var createEquipmentModel = new CreateEquipmentModel
                {
                    SerialNumber = "A0B1C2D3E4F5",
                    LocationID = "HEADEND 04 INVENTORY",
                    Status = "IGNORE",
                    SelectedModel = "VEN401",
                    UnitAddress = "A0:B1:C2:D3:E4:F5",
                    Category = EquipmentCategoryDto.VideoAccessPoint.ToString()
                };

                //This is for creating a Fault exception
                const string expectedErrorMessage = "This is a fault exception message";
                var faultDetail = new ValidationDetailDto()
                {
                    Message = expectedErrorMessage
                };

                var faultDetails = new List<ValidationDetailDto> { faultDetail };

                var validationFault = new ValidationFaultDto()
                {
                    Details = faultDetails
                };

                var fault = new FaultException<ValidationFaultDto>(validationFault);

                //Have Controller CreateEquipment method throw the fault when called
                ShimRosettianClient.AllInstances.CreateEquipmentEquipmentDtoUserDto = delegate { throw fault; };

                //Act
                var searchController = DependencyResolver.Current.GetService<SearchController>();
                var actionResponse = searchController.CreateEquipment(createEquipmentModel) as JsonResult;

                //Assert
                // Then the user receives a response
                Assert.IsNotNull(actionResponse, "CreateEquipment method returned null");

                //Data was returned
                Assert.IsNotNull(actionResponse.Data, "CreateEquipment response data is null");
                var jss = new JavaScriptSerializer();

                //The data is expected to be an error
                var expectedResult = new
                {
                    status = "error",
                    errorMessage = "This is a fault exception message"
                }.ToJSON();
                Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResponse.Data.ToJSON()));
            }
        }
        public void User_Attempts_To_create_a_new_location_with_correct_data_and_an_error_is_returned()
        {
            using (ShimsContext.Create())
            {
                //Arrange

                // Given a user that has permission to create new location
                ShimCurrentUser.AsUserDto = new SIMPLTestContext().GetFakeUserDtoObject;

                // And the new location to be created
                var createLocModel = new CreateLocationModel
                {
                    LocationID = "1234567",
                    Address1 = "MYADDRESS1",
                    Address2 = "MYADDRESS2",
                    City = "MYCITY",
                    State = "MYSTATE",
                    ZipCode = "MYZIPCODE",
                    MaxBandwidth = "25",
                    NetworkLocationCode = "MYNETWORKLOCATIONCODE",
                    RateCenter = "MYRATECENTER"
                };

                var searchController = DependencyResolver.Current.GetService<SearchController>();

                //This is for creating a Fault exception
                const string expectedErrorMessage = "This is a fault exception message";
                var faultDetail = new ValidationDetailDto()
                {
                    Message = expectedErrorMessage
                };

                var faultDetails = new List<ValidationDetailDto>();
                faultDetails.Add(faultDetail);

                var validationFault = new ValidationFaultDto()
                {
                    Details = faultDetails
                };

                var fault = new FaultException<ValidationFaultDto>(validationFault);

                //Have Controller CreateLocation method throw the fault when called
                ShimRosettianClient.AllInstances.CreateLocationLocationDtoUserDto = delegate { throw fault; };

                //Act

                //Call the actual controller method
                var actionResponse = searchController.CreateLocation(createLocModel) as JsonResult;

                //Assert

                // Then the user receives a response
                Assert.IsNotNull(actionResponse, "CreateLocation json result is null");
                Assert.IsNotNull(actionResponse.Data, "CreateLocation json result data is null");

                // And the expected response is a Fault exception
                var jss = new JavaScriptSerializer();
                var expectedResult = new
                {
                    status = "error",
                    isModal = false,
                    errorMessage = "This is a fault exception message"
                }.ToJSON();
                Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResponse.Data.ToJSON()));
            }
        }