public void Search_Subscriber_Using_Viryanet_Call_ID()
        {
            using (ShimsContext.Create())
            {
                var myContext = new SIMPLTestContext();

                ShimCurrentUser.AsUserDto = new SIMPLTestContext().GetFakeUserDtoObject;

                var fakeCallID = "7777";

                var subscriberSearchViewModel = new SubscriberSearchViewModel
                {
                    CallID = fakeCallID,
                    State = "CT"
                };

                var expectedSearchResults = new List<SubscriberSearchResult>();
                var record = new SubscriberSearchResult
                {
                    ID = "1",
                    Name = "ViryanetTestName",
                    ExistsInBilling = true,
                    DataSource = SubscriberEnums.SubscriberDataSource.Billing,
                    Environment = "Test"
                };
                expectedSearchResults.Add(record);

                var expectedResult = new
                {
                    status = "partialsuccessbilling",
                    isModal = false,
                    searchResults = expectedSearchResults,
                    provisioned = false

                }.ToJSON();

                var fakeSubscriberList = new BillingSearchSubscriberResponse();
                var fakeSubscriber = new BillingSearchSubscriber();
                fakeSubscriber.USI = "1";
                fakeSubscriber.SubscriberName = "ViryanetTestName";
                fakeSubscriber.Environment = "Test";
                fakeSubscriberList.Add(fakeSubscriber);

                ShimErrorLoggingService.AllInstances.LogErrorNoContextException = delegate { };
                //Search Subscriber from provisioning
                ShimProvisioningServiceClient.AllInstances.SearchSubscribersSearchFieldsUser =
                    delegate
                    {
                        return new SubscriberCollection();
                    };

                //Search Subscriber from billing
                ShimBillingServiceClient.AllInstances.SearchSubscriberBillingSearchFieldsUser =
                    delegate
                    {
                        return fakeSubscriberList;
                    };

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

                var actionResult = searchController.SearchCompositeSubscribers(subscriberSearchViewModel) as JsonResult;

                Assert.IsNotNull(actionResult, "SearchSubscribers  returned null");

                var actualJsonResult = actionResult.Data.ToJSON().Replace(" ", "");

                Assert.AreEqual(expectedResult, actualJsonResult);
            }
        }
        public void Search_Subscriber_Using_BillingOnlyFields()
        {
            using (ShimsContext.Create())
            {
                var myContext = new SIMPLTestContext();

                ShimCurrentUser.AsUserDto = new SIMPLTestContext().GetFakeUserDtoObject;

                var subscriberSearchViewModel = new SubscriberSearchViewModel
                {
                    AccountNumber = DataConversion(Convert.ToString(TestContext.DataRow["AccountNumber"])),
                    OrderNumber = DataConversion(Convert.ToString(TestContext.DataRow["OrderNumber"])),
                    DslamOltClli = DataConversion(Convert.ToString(TestContext.DataRow["DslamOltClli"])),
                    DslamOltPort = DataConversion(Convert.ToString(TestContext.DataRow["DslamOltPort"])),
                    State="CT"

                };

                var expectedSearchResults = new List<SubscriberSearchResult>();
                var record1 = new SubscriberSearchResult
                {
                    ID = "1",
                    Name = "Subscriber_1",
                    ExistsInBilling = true,
                    ExistsInProvisioning = false,
                    DataSource = SubscriberEnums.SubscriberDataSource.Billing,
                    Environment = "Test",
                    StateName = null
                };

                expectedSearchResults.Add(record1);

                var expectedResult = new
                {
                    status = "partialsuccessbilling",
                    isModal = false,
                    searchResults = expectedSearchResults,
                    provisioned = false

                }.ToJSON();

                var fakeSubscriberList = new BillingSearchSubscriberResponse();
                var fakeSubscriber = new BillingSearchSubscriber();
                fakeSubscriber.USI = record1.ID;
                fakeSubscriber.SubscriberName = record1.Name;
                fakeSubscriber.Environment = "Test";
                fakeSubscriberList.Add(fakeSubscriber);

                ShimErrorLoggingService.AllInstances.LogErrorNoContextException = delegate { };

                ShimBillingServiceClient.AllInstances.SearchSubscriberBillingSearchFieldsUser =
                    delegate
                    {
                        return fakeSubscriberList;
                    };

                bool isProvisioningMethodCalled = false;
                ShimProvisioningServiceClient.AllInstances.SearchSubscribersSearchFieldsUser =
                   delegate
                   {
                       isProvisioningMethodCalled = true;
                       return new SubscriberCollection();
                   };

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

                var actionResult = searchController.SearchCompositeSubscribers(subscriberSearchViewModel) as JsonResult;

                Assert.IsNotNull(actionResult, "SearchSubscribers  returned null");

                var actualJsonResult = actionResult.Data.ToJSON().Replace(" ", "");

                Assert.IsFalse(isProvisioningMethodCalled, "Provisioning service method should not be called.");
                Assert.AreEqual(expectedResult, actualJsonResult);
            }
        }