public async Task GetFilters_ShouldReturnFiltersOfTypeAndGrainIdOnly() { var runtime = TestHelpers.MockRuntime(); var grain = new FilterGrain(Substitute.For <IGrainIdentity>(), runtime); await grain.OnActivateAsync(); await grain.UpdateTypeFilters("TestType1", new List <FilterRow>() { new FilterRow("TestType1_Filter1", "Filter 1 Value") { GrainId = "1" }, new FilterRow("TestType1_Filter2", "Filter 2 Value") { GrainId = "2" } }); await grain.UpdateTypeFilters("TestType2", new List <FilterRow>() { new FilterRow("TestType2_Filter1", "Filter 1 Value") { GrainId = "3" }, new FilterRow("TestType2_Filter2", "Filter 2 Value") { GrainId = "4" } }); var filterRows = await grain.GetFilters("TestType1", "1"); Assert.NotEmpty(filterRows); Assert.Single(filterRows); }
public async Task UpdateTypeFilters_IfThereIsFiltersOfPassedType_ShouldAddToThatFilterNotCreateaNewFilterForList() { var runtime = TestHelpers.MockRuntime(); var grain = new FilterGrain(Substitute.For <IGrainIdentity>(), runtime); await grain.OnActivateAsync(); await grain.UpdateTypeFilters("TestType", new List <FilterRow>() { new FilterRow("Filter1", "Filter 1 Value") }); await grain.UpdateTypeFilters("TestType", new List <FilterRow>() { new FilterRow("Filter2", "Filter 2 Value") }); var filterForType = await grain.GetFilters(new [] { "TestType" }); Assert.NotEmpty(filterForType); Assert.Single(filterForType); }
public async Task UpdateTypeFilters_WhenFilterAlreadyInTypeFilterList_ShouldUpdateTheValue() { var runtime = TestHelpers.MockRuntime(); var grain = new FilterGrain(Substitute.For <IGrainIdentity>(), runtime); await grain.OnActivateAsync(); await grain.UpdateTypeFilters("TestType", new List <FilterRow>() { new FilterRow("Filter1", "Filter 1 Value") }); await grain.UpdateTypeFilters("TestType", new List <FilterRow>() { new FilterRow("Filter1", "Filter 1 NewValue") }); var filterForType = await grain.GetFilters(new[] { "TestType" }); Assert.NotEmpty(filterForType); Assert.Single(filterForType); Assert.True(filterForType.First().Filters.First().Value == "Filter 1 NewValue"); }
public async Task GetFilters_ShouldReturnAllFiltersFromGrain() { var runtime = TestHelpers.MockRuntime(); var grain = new FilterGrain(Substitute.For <IGrainIdentity>(), runtime); await grain.OnActivateAsync(); await grain.UpdateTypeFilters("TestType1", new List <FilterRow>() { new FilterRow("TestType1_Filter1", "Filter 1 Value"), new FilterRow("TestType1_Filter2", "Filter 2 Value") }); await grain.UpdateTypeFilters("TestType2", new List <FilterRow>() { new FilterRow("TestType2_Filter1", "Filter 1 Value"), new FilterRow("TestType2_Filter2", "Filter 2 Value") }); var filters = await grain.GetFilters(new [] { "TestType1", "TestType2" }); Assert.NotEmpty(filters); Assert.True(filters.Count == 2); }