コード例 #1
0
        public void GivenServiceCategoryFiltersExistInRequest_WhenIConstruct_ThenServiceCategoriesPopulated()
        {
            MockRequest.Expect(m => m["ServiceCategoryFilters"]).Return("Tuna|Salmon|Bass");
            ServiceOfferingClientDataTable target = new ServiceOfferingClientDataTable(MockRequest, CurrentUser);

            CollectionAssert.AreEqual(new string[] { "Tuna", "Salmon", "Bass" }, target.ServiceCategories.ToList());
        }
コード例 #2
0
        public void GivenServiceOffering_WhenInvokeDataSelector_ThenDataContainsExpectedProperties()
        {
            bool            expectedIsFavorite        = true;
            bool            expectedIsProviate        = true;
            string          expectedServiceTypeName   = "jw29fij2";
            string          expectedProviderName      = "slkdjfsdkljfs";
            string          expectedProgramName       = "wjovjwiojw";
            int             expectedServiceOfferingId = 382;
            ServiceOffering offering = new ServiceOffering
            {
                UsersLinkingAsFavorite = new List <User> {
                    CurrentUser.Identity.User
                },
                ServiceType = new ServiceType {
                    Name = expectedServiceTypeName, IsPrivate = expectedIsProviate
                },
                Provider = new Provider {
                    Name = expectedProviderName
                },
                Program = new Program {
                    Name = expectedProgramName
                },
                Id = expectedServiceOfferingId
            };
            ServiceOfferingClientDataTable target = new ServiceOfferingClientDataTable(MockRequest, CurrentUser);

            dynamic actual = target.DataSelector.Compile().Invoke(offering);

            Assert.AreEqual(expectedIsFavorite, actual.IsFavorite);
            Assert.AreEqual(expectedIsProviate, actual.IsPrivate);
            Assert.AreEqual(expectedServiceTypeName, actual.ServiceType);
            Assert.AreEqual(expectedProviderName, actual.Provider);
            Assert.AreEqual(expectedProgramName, actual.Program);
            Assert.AreEqual(expectedServiceOfferingId, actual.Id);
        }
コード例 #3
0
        public void GivenServiceTypeProviderOrProgramInRequest_WhenIConstruct_ThenServiceTypeProviderOrProgramNamePopulated()
        {
            MockRequest.Expect(m => m["ServiceTypeProviderOrProgram"]).Return("Test");
            ServiceOfferingClientDataTable target = new ServiceOfferingClientDataTable(MockRequest, CurrentUser);

            Assert.AreEqual("Test", target.ServiceTypeProviderOrProgramName);
        }
コード例 #4
0
        public void GivenServiceTypeFiltersExistInRequest_WhenIConstruct_ThenServiceTypesPopulated()
        {
            MockRequest.Expect(m => m["ServiceTypeFilters"]).Return("Apples|Oranges|Grapes");
            ServiceOfferingClientDataTable target = new ServiceOfferingClientDataTable(MockRequest, CurrentUser);

            CollectionAssert.AreEqual(new string[] { "Apples", "Oranges", "Grapes" }, target.ServiceTypes.ToList());
        }
コード例 #5
0
        public void GivenIsActiveIsFalse_WhenIExecuteFilterPredicate_ThenReturnFalse()
        {
            ServiceOffering argument = new ServiceOffering {
                IsActive = false
            };
            ServiceOfferingClientDataTable target = new ServiceOfferingClientDataTable(MockRequest, CurrentUser);

            Assert.IsFalse(target.FilterPredicate.Compile().Invoke(argument));
        }
コード例 #6
0
        public void GivenServiceTypeFiltersExistInRequest_AndServiceOfferingDoesNotMatchFilter_WhenIExecuteFilterPredicate_ThenServiceOfferingIsNotSelected()
        {
            ServiceOffering argument = new ServiceOffering {
                ServiceType = new ServiceType {
                    Name = "Purple"
                }
            };

            MockRequest.Expect(m => m["ServiceTypeFilters"]).Return("Apples|Oranges|Grapes");
            ServiceOfferingClientDataTable target = new ServiceOfferingClientDataTable(MockRequest, CurrentUser);

            Assert.IsFalse(target.FilterPredicate.Compile().Invoke(argument));
        }
コード例 #7
0
        public void GivenServiceOffering_AndUserIsDataAdmin_WhenInvokeDataSelector_ThenDataCanInteract()
        {
            ServiceOffering offering = new ServiceOffering
            {
                Provider    = new Provider(),
                ServiceType = new ServiceType(),
                Program     = new Program()
            };

            CurrentUser.Identity.User.UserRoles.Add(new UserRole {
                Role = new Role {
                    Name = SecurityRoles.DataAdmin
                }
            });
            ServiceOfferingClientDataTable target = new ServiceOfferingClientDataTable(MockRequest, CurrentUser);

            dynamic actual = target.DataSelector.Compile().Invoke(offering);

            Assert.AreEqual(true, actual.CanInteract);
        }