Example #1
0
            public async Task Updates_PublicUrls_On_Existing_Item()
            {
                var services = new[] {
                    new Service()
                    {
                        ServiceId = "Test1"
                    },
                    new Service()
                    {
                        ServiceId = "Test2"
                    },
                    new Service()
                    {
                        ServiceId = "Test3"
                    },
                };
                var store = new InMemoryServiceStore(services);

                await store.StoreAsync(new Service()
                {
                    ServiceId = "Test2", PublicUrls = new [] { new Uri("Http://test.com") }
                });

                var service = await store.FindByServiceIdAsync("Test2");

                service.Should().NotBeNull();
                service.PublicUrls.Should().HaveCount(1);
                service.PublicUrls[0].Should().Be(new Uri("http://test.com"));
            }
Example #2
0
            public async Task Updates_IpAddresses_On_Existing_Item()
            {
                var services = new[] {
                    new Service()
                    {
                        ServiceId = "Test1"
                    },
                    new Service()
                    {
                        ServiceId = "Test2"
                    },
                    new Service()
                    {
                        ServiceId = "Test3"
                    },
                };
                var store = new InMemoryServiceStore(services);

                await store.StoreAsync(new Service()
                {
                    ServiceId = "Test2", IpAddresses = new [] { "10.10.0.2" }
                });

                var service = await store.FindByServiceIdAsync("Test2");

                service.Should().NotBeNull();
                service.IpAddresses.Should().HaveCount(1);
                service.IpAddresses[0].Should().Be("10.10.0.2");
            }
Example #3
0
            public async Task Adds_Service_To_List()
            {
                var services = new[] {
                    new Service()
                    {
                        ServiceId = "Test1"
                    },
                    new Service()
                    {
                        ServiceId = "Test2"
                    }
                };
                var store = new InMemoryServiceStore(services);

                (await store.GetAllAsync()).Should().HaveCount(2);

                await store.StoreAsync(new Service()
                {
                    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");
            }
Example #4
0
            public async Task Removes_Existing_Item()
            {
                var services = new[] {
                    new Service()
                    {
                        ServiceId = "Test1"
                    },
                    new Service()
                    {
                        ServiceId = "Test2"
                    },
                    new Service()
                    {
                        ServiceId = "Test3"
                    },
                };
                var store = new InMemoryServiceStore(services);

                (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");
            }
Example #5
0
            public async Task Returns_All_Items()
            {
                var services = new[] {
                    new Service()
                    {
                        ServiceId = "Test1"
                    },
                    new Service()
                    {
                        ServiceId = "Test2"
                    },
                    new Service()
                    {
                        ServiceId = "Test3"
                    },
                };
                var store = new InMemoryServiceStore(services);

                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");
            }
Example #6
0
            public async Task Returns_Null_For_Non_Existing_Service()
            {
                var services = new[] {
                    new Service()
                    {
                        ServiceId = "Test1"
                    },
                    new Service()
                    {
                        ServiceId = "Test2"
                    }
                };
                var store = new InMemoryServiceStore(services);

                var item = await store.FindByServiceIdAsync("sdfsdfdsf");

                item.Should().BeNull();
            }
Example #7
0
            public void Does_Not_Throw_When_Service_Not_Exists()
            {
                var services = new[] {
                    new Service()
                    {
                        ServiceId = "Test1"
                    },
                    new Service()
                    {
                        ServiceId = "Test2"
                    },
                    new Service()
                    {
                        ServiceId = "Test3"
                    },
                };
                var store = new InMemoryServiceStore(services);

                Func <Task> action = async() => await store.RemoveAsync("teseeesr");

                action.Should().NotThrow();
            }