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