Exemple #1
0
        public void Read_Always_ShouldReturnAllOperations()
        {
            const string id       = "id";
            var          version1 = new Value {
                Content = "content", IsDeleted = false, Revision = 0
            };

            using (SimpleStorageTestHelpers.StartService(port))
            {
                storageClient.Put(id, version1);
                var version2 = new Value {
                    IsDeleted = true, Revision = 1, Content = "anotherContent"
                };
                storageClient.Put(id, version2);

                var actual = operationLogClient.Read(0, 100).ToArray();

                Assert.That(actual.Length, Is.EqualTo(2));
                Assert.That(actual[0].Id, Is.EqualTo(id));
                Assert.That(actual[0].Value.Content, Is.EqualTo(version1.Content));
                Assert.That(actual[0].Value.IsDeleted, Is.False);
                Assert.That(actual[1].Id, Is.EqualTo(id));
                Assert.That(actual[1].Value.IsDeleted, Is.True);
            }
        }
Exemple #2
0
 public void Read_BigPosition_ShouldReturnEmpty()
 {
     using (SimpleStorageTestHelpers.StartService(port))
     {
         var actual = operationLogClient.Read(1000, 1).ToArray();
         Assert.That(actual.Length, Is.EqualTo(0));
     }
 }
Exemple #3
0
        public void Get_UnknownId_ShouldReturnNotFound()
        {
            var requestUri = endpoint + "api/admin/internalGet/unknownId";

            using (SimpleStorageTestHelpers.StartService(port))
                using (var httpClient = new HttpClient())
                    using (var response = httpClient.GetAsync(requestUri).Result)
                        Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
        }
Exemple #4
0
        public void Get_StopInstance_ShouldThrow()
        {
            using (SimpleStorageTestHelpers.StartService(port))
                using (var httpClient = new HttpClient())
                {
                    using (
                        var response =
                            httpClient.PostAsync(endpoint + "api/admin/stop", new ByteArrayContent(new byte[0])).Result)
                        Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));

                    using (var response = httpClient.GetAsync(endpoint + "api/admin/internalGet/id").Result)
                        Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.InternalServerError));
                }
        }
Exemple #5
0
        public void Get_KnownId_ShouldReturnValue()
        {
            const string id    = "id";
            var          value = new Value {
                Content = "content"
            };

            using (SimpleStorageTestHelpers.StartService(port))
            {
                client.Put(id, value);
                var actual = client.Get(id);
                Assert.That(actual.Content, Is.EqualTo(value.Content));
            }
        }
Exemple #6
0
        public void Read_WithSeek_ShouldSkip()
        {
            using (SimpleStorageTestHelpers.StartService(port))
            {
                storageClient.Put("id1", new Value {
                    Content = "1"
                });
                storageClient.Put("id2", new Value {
                    Content = "2"
                });
                storageClient.Put("id3", new Value {
                    Content = "3"
                });

                var actual = operationLogClient.Read(1, 1).ToArray();

                Assert.That(actual.Length, Is.EqualTo(1));
            }
        }
        public void Get_StartInstance_ShouldNotThrow()
        {
            using (SimpleStorageTestHelpers.StartService(port))
            {
                client.Put("id", new Value());
                using (var httpClient = new HttpClient())
                {
                    using (
                        var response =
                            httpClient.PostAsync(endpoint + "api/admin/stop", new ByteArrayContent(new byte[0])).Result)
                        Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));

                    using (
                        var response =
                            httpClient.PostAsync(endpoint + "api/admin/start", new ByteArrayContent(new byte[0])).Result
                        )
                        Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));

                    using (var response = httpClient.GetAsync(endpoint + "api/values/id").Result)
                        Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                }
            }
        }