public void ShouldCallContainsKeysMethodOnLookupInterface() { var dictionary = new TestLookup(20); Assert.That(dictionary, Does.ContainKey(20)); Assert.That(dictionary, !Does.ContainKey(43)); }
public void FilterByCheckIds_NoIdProperty_Throws() { TestLookup <NoIdModel> testLookup = new TestLookup <NoIdModel>(); LookupException exception = Assert.Throws <LookupException>(() => testLookup.FilterByCheckIds(null, null)); String expected = $"'{typeof(NoIdModel).Name}' type does not have key or property named 'Id', required for automatic id filtering."; String actual = exception.Message; Assert.Equal(expected, actual); }
public void FilterBySelected_NoIdProperty_Throws() { TestLookup <NoIdModel> testLookup = new TestLookup <NoIdModel>(); LookupException exception = Assert.Throws <LookupException>(() => testLookup.FilterBySelected(Array.Empty <NoIdModel>().AsQueryable(), Array.Empty <String>())); String expected = $"'{typeof(NoIdModel).Name}' type does not have key or property named 'Id', required for automatic id filtering."; String actual = exception.Message; Assert.Equal(expected, actual); }
public void AddId_EmptyValues() { TestLookup <NoIdModel> lookup = new TestLookup <NoIdModel>(); lookup.AddId(row, new NoIdModel()); KeyValuePair <String, String> actual = row.Single(); Assert.Equal(MvcLookup.IdKey, actual.Key); Assert.Null(actual.Value); }
public MvcLookupOfTTests() { row = new Dictionary<String, String>(); lookup = new TestLookup<TestModel>(); lookup.Filter.Page = 0; for (Int32 i = 0; i < 20; i++) lookup.Models.Add(new TestModel { Id = i + "I", Count = i + 10, Value = i + "V", Date = new DateTime(2014, 12, 10).AddDays(i) }); }
public LookupExtensionsTests() { html = MockHtmlHelper(); lookup = new TestLookup<TestModel>(); lookup.Filter.Page = 2; lookup.Filter.Rows = 11; lookup.Filter.Search = "Test"; lookup.AdditionalFilters.Clear(); lookup.Filter.SortColumn = "First"; lookup.Title = "Dialog lookup title"; lookup.AdditionalFilters.Add("Add1"); lookup.AdditionalFilters.Add("Add2"); lookup.Url = "http://localhost/Lookup"; lookup.Filter.SortOrder = LookupSortOrder.Desc; }
public LookupExtensionsTests() { html = MockHtmlHelper(); lookup = new TestLookup <TestModel>(); lookup.Filter.Page = 2; lookup.Filter.Rows = 11; lookup.Filter.Search = "Test"; lookup.AdditionalFilters.Clear(); lookup.Filter.SortColumn = "First"; lookup.Title = "Dialog lookup title"; lookup.AdditionalFilters.Add("Add1"); lookup.AdditionalFilters.Add("Add2"); lookup.Url = "http://localhost/Lookup"; lookup.Filter.SortOrder = LookupSortOrder.Desc; }
public MvcLookupOfTTests() { row = new Dictionary <String, String>(); lookup = new TestLookup <TestModel>(); lookup.Filter.Page = 0; for (Int32 i = 0; i < 20; i++) { lookup.Models.Add(new TestModel { Id = i + "I", Count = i + 10, Value = i + "V", Date = new DateTime(2014, 12, 10).AddDays(i) }); } }
public MvcLookupOfTTests() { lookup = new TestLookup <TestModel>(); lookup.Filter.Page = 0; for (Int32 i = 0; i < 200; i++) { lookup.Models.Add(new TestModel { Id = i + "I", Count = i + 10, Value = i + "V", ParentId = "1000", Date = new DateTime(2014, 12, 10).AddDays(i) }); } }
public void FilterBySelected_NumberKey() { TestLookup <Int32Model> testLookup = new TestLookup <Int32Model>(); for (Int32 i = 0; i < 20; i++) { testLookup.Models.Add(new Int32Model { Value = i }); } IQueryable <Int32Model> actual = testLookup.FilterBySelected(testLookup.GetModels(), new List <String> { "9", "10" }); IQueryable <Int32Model> expected = testLookup.GetModels().Where(model => new[] { 9, 10 }.Contains(model.Value)); Assert.Equal(expected, actual); }
public MvcLookupOfTTests() { lookup = new TestLookup <TestModel>(); lookup.Filter.Rows = 20; for (Int32 i = 0; i < 200; i++) { lookup.Models.Add(new TestModel { Id = i + "I", Count = i + 10, ParentId = "1000", Value = $"{i}Value{i + 1}", NextValue = $"{i + 1}Value", Date = new DateTime(2014, 12, 10).AddDays(i) }); } }
public void FilterById_Number() { TestLookup <NumericModel> lookup = new TestLookup <NumericModel>(); for (Int32 i = 0; i < 20; i++) { lookup.Models.Add(new NumericModel { Id = i }); } lookup.Filter.Id = "9.0"; IQueryable <NumericModel> expected = lookup.GetModels().Where(model => model.Id == 9); IQueryable <NumericModel> actual = lookup.FilterById(lookup.GetModels()); Assert.Equal(expected, actual); }
public LookupExtensionsTests() { html = MockHtmlHelper(); lookup = new TestLookup <TestModel>(); lookup.Filter.Rows = 11; lookup.Dialog = "Dialog"; lookup.Filter.Offset = 22; lookup.Name = "LookupName"; lookup.Filter.Sort = "First"; lookup.Placeholder = "Search"; lookup.Filter.Search = "Test"; lookup.AdditionalFilters.Clear(); lookup.AdditionalFilters.Add("Add1"); lookup.AdditionalFilters.Add("Add2"); lookup.Title = "Dialog lookup title"; lookup.Url = "http://localhost/Lookup"; lookup.Filter.Order = LookupSortOrder.Desc; }
public void FilterByNotIds_Guids() { TestLookup <GuidModel> testLookup = new TestLookup <GuidModel>(); for (Int32 i = 0; i < 20; i++) { testLookup.Models.Add(new GuidModel { Id = Guid.NewGuid() }); } List <String> ids = new List <String> { testLookup.Models[4].Id.ToString(), testLookup.Models[9].Id.ToString() }; IQueryable <GuidModel> expected = testLookup.GetModels().Where(model => !ids.Contains(model.Id.ToString())); IQueryable <GuidModel> actual = testLookup.FilterByNotIds(testLookup.GetModels(), ids); Assert.Equal(expected, actual); }
public void Contains() { Assert.True(TestLookup.Contains("VT")); }
public void DoesNotContain() { Assert.False(TestLookup.Contains("ZZ")); }
public void FilterById_NoIdProperty_Throws() { TestLookup<NoIdModel> lookup = new TestLookup<NoIdModel>(); LookupException exception = Assert.Throws<LookupException>(() => lookup.FilterById(null)); String expected = $"'{typeof (NoIdModel).Name}' type does not have property named 'Id', required for automatic id filtering."; String actual = exception.Message; Assert.Equal(expected, actual); }
public void FilterById_Number() { TestLookup<NumericModel> lookup = new TestLookup<NumericModel>(); for (Int32 i = 0; i < 20; i++) lookup.Models.Add(new NumericModel { Id = i }); lookup.Filter.Id = "9.0"; IQueryable<NumericModel> expected = lookup.GetModels().Where(model => model.Id == 9); IQueryable<NumericModel> actual = lookup.FilterById(lookup.GetModels()); Assert.Equal(expected, actual); }
public void AddId_EmptyValues() { TestLookup<NoIdModel> lookup = new TestLookup<NoIdModel>(); lookup.AddId(row, new NoIdModel()); KeyValuePair<String, String> actual = row.Single(); Assert.Equal(MvcLookup.IdKey, actual.Key); Assert.Null(actual.Value); }