public async Task Updates_Document_On_Existing_Item() { var apiDescriptions = new[] { new ServiceApiDescription() { ServiceId = "Test1" }, new ServiceApiDescription() { ServiceId = "Test2" }, new ServiceApiDescription() { ServiceId = "Test3" }, }; var store = new InMemoryApiStore(apiDescriptions); await store.StoreAsync(new ServiceApiDescription() { ServiceId = "Test2", ApiDocument = new Microsoft.OpenApi.Models.OpenApiDocument() }); var service = await store.FindByServiceIdAsync("Test2"); service.Should().NotBeNull(); service.ApiDocument.Should().NotBeNull(); }
public async Task Adds_Api_To_List() { var apiDescriptions = new[] { new ServiceApiDescription() { ServiceId = "Test1" }, new ServiceApiDescription() { ServiceId = "Test2" } }; var store = new InMemoryApiStore(apiDescriptions); (await store.GetAllAsync()).Should().HaveCount(2); await store.StoreAsync(new ServiceApiDescription() { ServiceId = "Test3" }); var items = await store.GetAllAsync(); items.Should().HaveCount(3); items.Should().Contain(s => s.ServiceId == "Test1"); items.Should().Contain(s => s.ServiceId == "Test2"); items.Should().Contain(s => s.ServiceId == "Test3"); }
public async Task Removes_Existing_Item() { var apiDescriptions = new[] { new ServiceApiDescription() { ServiceId = "Test1" }, new ServiceApiDescription() { ServiceId = "Test2" }, new ServiceApiDescription() { ServiceId = "Test3" }, }; var store = new InMemoryApiStore(apiDescriptions); (await store.GetAllAsync()).Should().HaveCount(3); await store.RemoveAsync("Test2"); var items = await store.GetAllAsync(); items.Should().HaveCount(2); items.Should().Contain(s => s.ServiceId == "Test1"); items.Should().Contain(s => s.ServiceId == "Test3"); items.Should().NotContain(s => s.ServiceId == "Test2"); }
public async Task Returns_All_Items() { var apiDescriptions = new[] { new ServiceApiDescription() { ServiceId = "Test1" }, new ServiceApiDescription() { ServiceId = "Test2" }, new ServiceApiDescription() { ServiceId = "Test3" }, }; var store = new InMemoryApiStore(apiDescriptions); var items = await store.GetAllAsync(); items.Should().HaveCount(3); items.Should().Contain(s => s.ServiceId == "Test1"); items.Should().Contain(s => s.ServiceId == "Test2"); items.Should().Contain(s => s.ServiceId == "Test3"); }
public async Task Returns_Null_For_Non_Existing_Api() { var apiDescriptions = new[] { new ServiceApiDescription() { ServiceId = "Test1" }, new ServiceApiDescription() { ServiceId = "Test2" } }; var store = new InMemoryApiStore(apiDescriptions); var item = await store.FindByServiceIdAsync("sdfsdfdsf"); item.Should().BeNull(); }
public void Does_Not_Throw_When_Api_Not_Exists() { var apiDescriptions = new[] { new ServiceApiDescription() { ServiceId = "Test1" }, new ServiceApiDescription() { ServiceId = "Test2" }, new ServiceApiDescription() { ServiceId = "Test3" }, }; var store = new InMemoryApiStore(apiDescriptions); Func <Task> action = async() => await store.RemoveAsync("teseeesr"); action.Should().NotThrow(); }