Ejemplo n.º 1
0
        public void When_searching_by_location_can_load_a_subscriber()
        {
            //Setup
            var myContext = new SIMPLTestContext();
            const string subscriberID = "999999999999";
            const string subscriberContactPhone = "9999999999";
            const string firstName = "Test";
            const string lastName = "Account";
            const string locationId = "9999999";

            using (ShimsContext.Create())
            {
                // Given a user
                var fakeUserDto = myContext.GetFakeUserDtoObject();
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                // And a known location
                var fakeAccountDto = myContext.GetFakeAccountDtoObject();
                fakeAccountDto.Location = myContext.GetFakeLocationDtoObject(locationId);

                // And the location is associated to a subscriber
                var fakeCustomFieldDto = myContext.GetFakeCustomFieldDto();
                var fakeSubscriberDto = new List<SubscriberDto>();
                fakeSubscriberDto.Add(myContext.GetFakeSubscriberDto(subscriberID, firstName, lastName, subscriberContactPhone, fakeCustomFieldDto, fakeAccountDto));

                ShimRosettianClient.AllInstances.SearchSubscribersSearchFieldsDtoUserDto = (myRosettianClient, mySearchFields, myUserDto) => fakeSubscriberDto;

                // When loading that location
                var actionResult = SubscriberControllerForTests.LoadLocation(locationId) as RedirectToRouteResult;

                // Then the user receives a response
                Assert.IsNotNull(actionResult, "SubscriberController LoadLocation method returned null");
                Assert.IsNotNull(actionResult.RouteValues, "actionResult.RouteValues is null");
                // And the response is successful
                // And the response redirects them to the subscriber index
                Assert.AreEqual(2, actionResult.RouteValues.Count, "actionResult.RouteValues.Count");
                Assert.AreEqual("Index", actionResult.RouteValues["action"], "actionResult.RouteValues[\"action\"]");

                // And the usi returned matches the billing usi
                Assert.AreEqual(subscriberID, actionResult.RouteValues["subID"], "actionResult.RouteValues[\"subID\"]");
            }
        }
Ejemplo n.º 2
0
        public void User_receives_an_error_when_trying_to_load_an_unknown_location()
        {
            //Setup
            var myContext = new SIMPLTestContext();
            const string locationId = "9999999";

            using (ShimsContext.Create())
            {
                // Given a user
                var fakeUserDto = myContext.GetFakeUserDtoObject();
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                // And an unknown location
                var fakeSubscriberDto = new List<SubscriberDto>();
                ShimRosettianClient.AllInstances.SearchSubscribersSearchFieldsDtoUserDto = (myRosettianClient, mySearchFields, myUserDto) => fakeSubscriberDto;
                var fakeLocationDto = myContext.GetFakeLocationDtoObject(locationId);

                var fakeValidationFault = new ValidationFaultDto()
                {
                    Details = new List<ValidationDetailDto>()
                    {
                        new ValidationDetailDto()
                        {
                            Key = "NA",
                            Message = "Error Message",
                            Tag = "NA"
                        }
                    }
                };

                ShimRosettianClient.AllInstances.LoadLocationStringUserDto =
                    (myRosettianClient, myLocationId, myUserDto) => { throw new FaultException<ValidationFaultDto>(fakeValidationFault); };

                // When loading that location
                var actionResult = SubscriberControllerForTests.LoadLocation(locationId) as PartialViewResult;

                // Then the user receives a response
                Assert.IsNotNull(actionResult, "SubscriberController LoadLocation method returned null");

                // And the response is an error
                Assert.AreEqual("Error Message", actionResult.ViewData["error"], string.Format("The response should have been Error Message, but was {0}", actionResult.ViewData["error"]));
            }
        }
Ejemplo n.º 3
0
        public void Can_load_a_device_that_is_at_a_provisioned_location_with_no_subscriber()
        {
            //Setup
            var myContext = new SIMPLTestContext();
            const string locationId = "123345";
            const string deviceId = "MRCC12341234D01";

            using (ShimsContext.Create())
            {
                // Given a user
                var fakeUserDto = myContext.GetFakeUserDtoObject();
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                // And a known device
                var fakeEquipmentDto = new List<EquipmentDto>()
                {
                    new EquipmentDto(){LocationId = "123345", SerialNumber = "MRCC12341234D01", Type = new EquipmentTypeDto(){ONTModel = new ONTModelDto()}}

                };

                // And the device is associated to a provisioned location
                var fakeLocationDto = myContext.GetFakeLocationDtoObject(locationId);
                var fakeLocationDtoList = new LocationCollectionDto()
                {
                    fakeLocationDto
                };

                // And the provisioned location is not associated to a subscriber

                ShimRosettianClient.AllInstances.SearchLocationsSearchFieldsDtoUserDto =
                    (myRosettianClient, mySearchCriteria, myUserDto) => fakeLocationDtoList;
                ShimRosettianClient.AllInstances.LoadLocationStringUserDto = delegate { return fakeLocationDto; };

                // And the location has no devices
                ShimRosettianClient.AllInstances.SearchEquipmentSearchFieldsDtoUserDto =
                    (myRosettianClient, mySearchFields, myUser) => fakeEquipmentDto;

                // And the location is not associated to a subscriber
                var fakeSubscriberDto = new List<SubscriberDto>();
                ShimRosettianClient.AllInstances.SearchSubscribersSearchFieldsDtoUserDto =
                    (myRosettianClient, mySearchFields, myUserDto) => fakeSubscriberDto;

                ShimDBCache.LocationsGet = delegate { return new List<Location>(); };

                // When loading that device
                var actionResult = SubscriberControllerForTests.LoadEquipment(deviceId) as ViewResult;

                // Then the user receives a response
                Assert.IsNotNull(actionResult, "SubscriberController LoadLocation method returned null");

                // And the response is successful
                Assert.IsNotNull(actionResult.Model, "Model was null");
                var actualModel = actionResult.Model as SubscriberModel;

                Assert.IsNotNull(actualModel, "Model was null");
                Assert.IsNotNull(actualModel.ActionResponse, "actualModel.ActionResponse was null");
                Assert.AreNotEqual("500", actualModel.ActionResponse.Code, "We received a 500 code as the actionresponse.");
                Assert.AreEqual("Index2", actionResult.ViewName, "actionResult.RouteValues[\"action\"]");

                // And the selected tab is the OSP/CPE tab
                Assert.AreEqual(3, actualModel.SelectedTabIndex, "The default tab was not the notes tab");
            }
        }
Ejemplo n.º 4
0
        public void User_can_load_a_location_that_is_not_associated_to_a_subscriber_with_no_devices()
        {
            //Setup
            var myContext = new SIMPLTestContext();
            const string locationId = "9999999";

            using (ShimsContext.Create())
            {
                // Given a user
                var fakeUserDto = myContext.GetFakeUserDtoObject();
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                // Fake the session state for HttpContext
                // http://blog.christopheargento.net/2013/02/02/testing-untestable-code-thanks-to-ms-fakes/
                var session = new ShimHttpSessionState();
                session.ItemGetString = (key) => { if (key == "LoadedLocation") return null; return null; };

                // 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;

                ShimCurrentSubscriber.UpdateSubscriberLocationModel = delegate { };

                // And a known location
                var fakeLocationDto = myContext.GetFakeLocationDtoObject(locationId);

                ShimRosettianClient.AllInstances.LoadLocationStringUserDto = (myRosettianClient, myLocationId, myUserDto) => fakeLocationDto;

                // And the location has no devices
                ShimRosettianClient.AllInstances.SearchEquipmentSearchFieldsDtoUserDto = (myRosettianClient, mySearchFields, myUser) => new List<EquipmentDto>();

                // And the location is not associated to a subscriber
                var fakeSubscriberDto = new List<SubscriberDto>();
                ShimRosettianClient.AllInstances.SearchSubscribersSearchFieldsDtoUserDto = (myRosettianClient, mySearchFields, myUserDto) => fakeSubscriberDto;

                // When loading that location
                var actionResult = SubscriberControllerForTests.LoadLocation(locationId) as ViewResult;

                // Then the user receives a response
                Assert.IsNotNull(actionResult, "SubscriberController LoadLocation method returned null");

                // And the response is successful
                Assert.AreEqual("Index2", actionResult.ViewName, "actionResult.RouteValues[\"action\"]");

                // And the response returns the location information
                var expectedModel = fakeLocationDto.MapToSubscriberModel();
                var actualModel = actionResult.Model as SubscriberModel;
                Assert.IsNotNull(actualModel, "The model returned was empty");
                Assert.IsNotNull(actualModel.SubLocationModel, "The sub location model returned was empty");
                Assert.IsTrue(expectedModel.SubLocationModel.Address1.Equals(actualModel.SubLocationModel.Address1), "The Address was different");

                // And the location matches the requested location
                Assert.AreEqual(locationId, actualModel.SubLocationModel.LocationID, "Location Id did not match the one that was searched for.");

                // And the notes tab is the selected tab
                Assert.AreEqual(5, actualModel.SelectedTabIndex, "The default tab was not the notes tab");
            }
        }
Ejemplo n.º 5
0
        public void Can_load_a_device_that_is_at_a_inventory_location()
        {
            //Setup
            var myContext = new SIMPLTestContext();
            const string locationId = "HEADEND";
            const string deviceId = "MRCC12341234D01";

            using (ShimsContext.Create())
            {
                // Given a user
                var fakeUserDto = myContext.GetFakeUserDtoObject();
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                // And a known device
                var fakeEquipmentDto = new List<EquipmentDto>()
                {
                    new EquipmentDto(){LocationId = locationId, SerialNumber = deviceId, Type = new EquipmentTypeDto(){ONTModel = new ONTModelDto()}}

                };

                // And the device is associated to a provisioned location
                var fakeLocationDto = myContext.GetFakeLocationDtoObject(locationId);
                var fakeLocationDtoList = new LocationCollectionDto()
                {
                    fakeLocationDto
                };

                // And the provisioned location is not associated to a subscriber
                fakeLocationDtoList[0].HasSubscriber = false;
                ShimRosettianClient.AllInstances.SearchLocationsSearchFieldsDtoUserDto =
                    (myRosettianClient, mySearchCriteria, myUserDto) => fakeLocationDtoList;

                // And the location has no devices
                ShimRosettianClient.AllInstances.SearchEquipmentSearchFieldsDtoUserDto =
                    (myRosettianClient, mySearchFields, myUser) => fakeEquipmentDto;

                // And the location has no devices
                ShimRosettianClient.AllInstances.LoadLocationStringUserDto =
                    (myRosettianClient, myLocId, myUser) => fakeLocationDto;

                // And the location is not associated to a subscriber
                var fakeSubscriberDto = new List<SubscriberDto>();
                ShimRosettianClient.AllInstances.SearchSubscribersSearchFieldsDtoUserDto =
                    (myRosettianClient, mySearchFields, myUserDto) => fakeSubscriberDto;

                // When loading that device
                var actionResult = SubscriberControllerForTests.LoadEquipment(deviceId) as ViewResult;

                // Then the user receives a response
                Assert.IsNotNull(actionResult, "SubscriberController LoadLocation method returned null");

                // And the response is successful
                Assert.IsNotNull(actionResult.Model, "Model was null");
                var actualModel = actionResult.Model as SubscriberModel;
                Assert.IsNotNull(actualModel, "Model was null");
                Assert.IsNotNull(actualModel.ActionResponse, "ActionResponse was null");
                Assert.IsNotNull(actualModel.ActionResponse.Code, "actualModelActionResponse.Code was null");
                Assert.AreNotEqual("500", actualModel.ActionResponse.Code, "We received a 500 code as the actionresponse.");
                Assert.AreEqual("Index2", actionResult.ViewName, "actionResult.RouteValues[\"action\"]");

                // And the selected tab is the OSP/CPE tab
                Assert.AreEqual(3, actualModel.SelectedTabIndex, "The default tab was not the notes tab");

                // And no equipment is returned
                Assert.IsTrue((actualModel.SubEquipmentModel.ONTList.Count == 0 && actualModel.SubEquipmentModel.VideoDeviceList.Count == 0), "Devices were returned in the model");

                //And the Loaded Device Id is the same as the searched for device
                Assert.AreEqual(deviceId, actualModel.SubLocationModel.LoadedDeviceID, "The returned loaded device ID was different then the one passed in");
            }
        }
Ejemplo n.º 6
0
        public void Search_Location_By_SubscriberID()
        {
            using (ShimsContext.Create())
            {
                //Arrange
                var myContext = new SIMPLTestContext();
                var fakeUserDto = myContext.GetFakeUserDtoObject();
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                //search criteria
                var locationSearchViewModel = new LocationSearchViewModel
                {
                    SubscriberID = "370001704986"
                };

                //expected search results
                var record = new[]
                    {
                        new
                        {
                            ID = "9999999",
                            AddressLine1 = "123 Fake St.",
                            AddressLine2 = "Apt 2",
                            CityName = "Fake City",
                            StateName = null as object,
                            ZipCode =null as object,
                            ZipPlusFourCode = null as object,
                            IsBillingAddress = false,
                            HeadendCode = "01",
                            HasSubscriber = true,
                            FacilityList = new Provisioning.FacilityDto[] {},
                            CustomFields = new CustomFieldDto[] {},
                            RateCenterName = "1234",
                            MaximumBandwidth =null as object,
                            NetworkLocationCode = null as object
                        }
                    };

                var expectedSearchResults = new
                {
                    status = "valid",
                    isModal = false,
                    searchResults = record

                }.ToJSON();

                var fakeLocationDto = myContext.GetFakeLocationDtoObject();
                var fakeLocationCollectionDto = new LocationCollectionDto()
                    {
                        fakeLocationDto
                    };

                ShimRosettianClient.AllInstances.SearchLocationsSearchFieldsDtoUserDto = delegate
                {
                    return fakeLocationCollectionDto;
                };

                var actionResult = SearchControllerForTests.SearchLocation(locationSearchViewModel) as JsonResult;
                Assert.IsNotNull(actionResult, "SearchSubscribers returned null");
                var actualJsonResult = actionResult.Data.ToJSON();
                Assert.AreEqual(expectedSearchResults, actualJsonResult);
            }
        }