Exemplo n.º 1
0
        public void GivenNoCriteria_AndProgramHasName_WhenExecuteFilterPredicate_ThenReturnTrue()
        {
            Program program = new Program {
                Name = "something", IsActive = true
            };
            ProgramClientDataTable target = new ProgramClientDataTable(MockRequest);

            Assert.IsTrue(target.FilterPredicate.Compile().Invoke(program));
        }
Exemplo n.º 2
0
        public void GivenNoCriteria_AndIsActiveIsFalse_WhenExecuteFilterPredicate_ThenReturnFalse()
        {
            Program program = new Program {
                IsActive = false
            };

            ProgramClientDataTable target = new ProgramClientDataTable(MockRequest);

            Assert.IsFalse(target.FilterPredicate.Compile().Invoke(program));
        }
Exemplo n.º 3
0
        public void GivenProgram_WhenExecuteSortSelector_ThenReturnProgramName()
        {
            string  expected = "something";
            Program program  = new Program {
                Name = expected
            };
            ProgramClientDataTable target = new ProgramClientDataTable(MockRequest);

            Assert.AreEqual(expected, target.SortSelector.Compile().Invoke(program));
        }
Exemplo n.º 4
0
        public void GivenNameCriteria_AndProgramNameContainsCriteria_WhenExecuteFilterPredicate_ThenReturnTrue()
        {
            Program program = new Program {
                Name = "different", IsActive = true
            };

            MockRequest.Expect(m => m["PartnerName"]).Return("fere");
            ProgramClientDataTable target = new ProgramClientDataTable(MockRequest);

            Assert.IsTrue(target.FilterPredicate.Compile().Invoke(program));
        }
Exemplo n.º 5
0
        public void GivenNameCriteriaIsEmptyString_AndProgramHasName_WhenExecuteFilterPredicate_ThenReturnTrue()
        {
            Program program = new Program {
                Name = "something", IsActive = true
            };

            MockRequest.Expect(m => m["PartnerName"]).Return(string.Empty);
            ProgramClientDataTable target = new ProgramClientDataTable(MockRequest);

            Assert.IsTrue(target.FilterPredicate.Compile().Invoke(program));
        }
Exemplo n.º 6
0
        public void GivenNameCriteria_AndProgramMatchesName_AndIsActiveIsFalse_WhenExecuteFilterPredicate_ThenReturnFalse()
        {
            Program program = new Program {
                Name = "name", IsActive = false
            };

            MockRequest.Expect(m => m["PartnerName"]).Return("name");
            ProgramClientDataTable target = new ProgramClientDataTable(MockRequest);

            Assert.IsFalse(target.FilterPredicate.Compile().Invoke(program));
        }
Exemplo n.º 7
0
        public void GivenProgram_WhenExecuteDataSelector_ThenIdMatches()
        {
            int     expected = 2842;
            Program program  = new Program {
                Id = expected
            };
            ProgramClientDataTable target = new ProgramClientDataTable(MockRequest);

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

            Assert.AreEqual(expected, actual.Id);
        }
Exemplo n.º 8
0
        public void GivenProgram_WhenExecuteDataSelector_ThenNamePropertyMatches()
        {
            string  expected = "something";
            Program program  = new Program {
                Name = expected
            };
            ProgramClientDataTable target = new ProgramClientDataTable(MockRequest);

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

            Assert.AreEqual(expected, actual.Name);
        }
Exemplo n.º 9
0
        public void GivenProgramWithSchools_WhenExecuteDataSelector_ThenSchoolListMatches()
        {
            string[] expected = new[] { "School1", "School2", "School3" };
            Program  program  = new Program
            {
                Schools = expected.Select(name => new School {
                    Name = name
                }).ToList()
            };
            ProgramClientDataTable target = new ProgramClientDataTable(MockRequest);

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

            CollectionAssert.AreEqual(expected, ((IEnumerable <string>)actual.Schools).ToList());
        }
Exemplo n.º 10
0
        public void GivenProgram_WhenExecuteDataSelector_ThenContactDataPropertyMatches()
        {
            Contact expectedState = new Contact {
                Name = "Bob", Phone = "123-456-7890", Email = "*****@*****.**"
            };
            Program program = new Program {
                ContactInfo = expectedState
            };
            ProgramClientDataTable target = new ProgramClientDataTable(MockRequest);

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

            Assert.AreEqual(expectedState.Name, actual.Contact.Name);
            Assert.AreEqual(expectedState.Phone, actual.Contact.Phone);
            Assert.AreEqual(expectedState.Email, actual.Contact.Email);
        }
Exemplo n.º 11
0
        public void GivenProgramWithProviders_WhenExecuteDataSelector_ThenServiceTypeListMatches()
        {
            string[] expected = new[] { "Apple", "Orange", "Banana" };
            Program  program  = new Program
            {
                ServiceOfferings = expected.Select(name => new ServiceOffering {
                    IsActive = true, ServiceType = new ServiceType {
                        Name = name
                    }
                }).ToList()
            };
            ProgramClientDataTable target = new ProgramClientDataTable(MockRequest);

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

            CollectionAssert.AreEqual(expected, ((IEnumerable <string>)actual.ServiceTypes).ToList());
        }
Exemplo n.º 12
0
        public void GivenNameCriteria_AndProgramAssociatedWithServiceTypeWithMatchingName_AndServiceTypeIsNotActive_WhenExecuteFilterPredicate_ThenReturnFalse()
        {
            Program program = new Program
            {
                Name             = "not the search criteria",
                ServiceOfferings = new List <ServiceOffering>
                {
                    new ServiceOffering
                    {
                        Provider    = new Provider(),
                        ServiceType = new ServiceType {
                            Name = "contains bLah criteria"
                        }
                    }
                },
                IsActive = true
            };

            MockRequest.Expect(m => m["PartnerName"]).Return("blah");
            ProgramClientDataTable target = new ProgramClientDataTable(MockRequest);

            Assert.IsFalse(target.FilterPredicate.Compile().Invoke(program));
        }