public async Task Service_Update_Without_Uuid_Successfully_Async()
        {
            //[A]rrange
            ClientTest client = new ClientTest {
                Age = ClientTest.MAX_AGE, Name = "Dr. Crawley"
            };
            //[A]ct
            ClientTest result = await provider.ServiceAsync.SaveAsync(client);

            //[A]ssert
            Assert.Equal(client, result);

            //[A]rrange
            client.Age--;
            client.Uuid = Guid.Empty;

            //[A]ct
            var beforeSave = DateTime.Now;

            result = await provider.ServiceAsync.UpdateAsync(client);

            //[A]ssert
            Assert.Equal(client, result);
            Assert.True(result.Id > 0L, "After update, result does not contains an ID!");
            Assert.True(result.Uuid != Guid.Empty, "After update, result does not contains an Uuid!");
            Assert.True(result.Updated > beforeSave, "After update, result does not contains a valid auditable Updated date time!");
        }
示例#2
0
        public void Service_Update_ByRecoveryId_Successfully()
        {
            //[A]rrange
            ClientTest client = new ClientTest {
                Age = ClientTest.MAX_AGE, Name = "Dr. Crawley"
            };
            //[A]ct
            ClientTest result = provider.Service.Save(client);

            //[A]ssert
            Assert.Equal(client, result);

            //[A]ct
            client = provider.ServiceWithId.Get(result.Id);
            //[A]ssert
            Assert.Equal(client.Id, result.Id);
            Assert.Equal(client.Uuid, result.Uuid);
            Assert.Equal(client.Age, result.Age);
            Assert.Equal(client.Name, result.Name);

            //[A]rrange
            client.Age--;
            client.Uuid = Guid.Empty;

            //[A]ct
            var beforeSave = DateTime.Now;

            result = provider.Service.Update(client);

            //[A]ssert
            Assert.Equal(client, result);
            Assert.True(result.Id > 0L, "After update, result does not contains an ID!");
            Assert.True(result.Uuid != Guid.Empty, "After update, result does not contains an Uuid!");
            Assert.True(result.Updated > beforeSave, "After update, result does not contains a valid auditable Updated date time!");
        }
示例#3
0
        public void Service_Update_Without_Id_Successfully()
        {
            //[A]rrange
            ClientTest client = new ClientTest {
                Age = ClientTest.MAX_AGE, Name = "Arthur Jeffries"
            };
            //[A]ct
            ClientTest result = provider.Service.Save(client);

            //[A]ssert
            Assert.Equal(client, result);

            //[A]rrange
            client.Age--;
            client.Id = 0;

            var beforeSave = DateTime.Now;

            result = provider.Service.Update(client);

            //[A]ssert
            Assert.Equal(client, result);
            Assert.True(result.Id > 0L, "After update, result does not contains an ID!");
            Assert.True(result.Uuid != Guid.Empty, "After update, result does not contains an Uuid!");
            Assert.True(result.Updated > beforeSave, "After update, result does not contains a valid auditable Updated date time!");
        }
        public async Task Service_Delete_By_Uuid_Successfully_Async()
        {
            //[A]rrange
            ClientTest client = await provider.ServiceAsync.FirstAsync();

            //[A]ct
            bool result = await provider.ServiceAsync.DeleteByUuidAsync(client.Uuid);

            //[A]ssert
            Assert.True(result, "Does not possible to delete value!");
        }
示例#5
0
        public void Service_Delete_By_Uuid_Successfully()
        {
            //[A]rrange
            ClientTest client = provider.Service.First();

            //[A]ct
            bool result = provider.Service.DeleteByUuid(client.Uuid);

            //[A]ssert
            Assert.True(result, "Does not possible to delete value!");
        }
        public async Task Service_Update_Error_FieldRequired_Async()
        {
            //[A]rrange
            ClientTest client = await provider.ServiceAsync.FirstAsync();

            client.Name = null;//required it.

            //[A]ct
            var ex = await Assert.ThrowsAnyAsync <DbUpdateException>(() => provider.ServiceAsync.UpdateAsync(client));

            //[A]ssert
            Assert.NotNull(ex);
        }
示例#7
0
        public void Service_Update_Error_FieldRequired()
        {
            //[A]rrange
            ClientTest client = provider.Service.First();

            client.Name = null;//required it.

            //[A]ct
            var ex = Assert.ThrowsAny <DbUpdateException>(() => provider.Service.Update(client));

            //[A]ssert
            Assert.NotNull(ex);
        }
        public async Task Service_Save_Error_FieldRequired_Async(int age, string name)
        {
            //[A]rrange
            ClientTest client = new ClientTest
            {
                Age  = age,
                Name = name
            };

            //[A]ct
            var ex = await Assert.ThrowsAnyAsync <DbUpdateException>(() => provider.ServiceAsync.SaveAsync(client));

            //[A]ssert
            Assert.NotNull(ex);
        }
        public async Task Service_Delete_Error_Untrackable_Async()
        {
            //[A]rrange
            ClientTest client = new ClientTest
            {
                Age  = ClientTest.MIN_AGE,
                Name = new string('a', ClientTest.MAX_NAME_LENGTH)
            };

            //[A]ct
            var ex = await Assert.ThrowsAnyAsync <InvalidOperationException>(() => provider.ServiceAsync.UpdateAsync(client));

            //[A]ssert
            Assert.NotNull(ex);
        }
示例#10
0
        public void Service_Save_Error_FieldRequired(int age, string name)
        {
            //[A]rrange
            ClientTest client = new ClientTest
            {
                Age  = age,
                Name = name
            };

            //[A]ct
            var ex = Assert.ThrowsAny <DbUpdateException>(() => provider.Service.Save(client));

            //[A]ssert
            Assert.NotNull(ex);
        }
示例#11
0
        public void Service_Delete_Error_Untrackable()
        {
            //[A]rrange
            ClientTest client = new ClientTest
            {
                Age  = ClientTest.MIN_AGE,
                Name = new string('a', ClientTest.MAX_NAME_LENGTH)
            };

            //[A]ct
            var ex = Assert.ThrowsAny <InvalidOperationException>(() => provider.Service.Delete(client));

            //[A]ssert
            Assert.NotNull(ex);
        }
示例#12
0
        public void Service_Save_Error_UniqueConstraintPrimaryKey(int age, string name)
        {
            //[A]rrange
            ClientTest client = new ClientTest
            {
                Age  = age,
                Name = name
            };

            //[A]ct
            ClientTest result = provider.Service.Save(client);
            var        ex     = Assert.ThrowsAny <DbUpdateException>(() => provider.Service.Save(result));

            //[A]ssert
            Assert.NotNull(ex);
        }
        public async Task Service_Save_Error_UniqueConstraintPrimaryKey_Async(int age, string name)
        {
            //[A]rrange
            ClientTest client = new ClientTest
            {
                Age  = age,
                Name = name
            };

            //[A]ct
            ClientTest result = await provider.ServiceAsync.SaveAsync(client);

            var ex = await Assert.ThrowsAnyAsync <DbUpdateException>(() => provider.ServiceAsync.SaveAsync(result));

            //[A]ssert
            Assert.NotNull(ex);
        }
        public async Task Service_Update_Successfully_Async(int page, int limit, int age, string name)
        {
            //[A]rrange
            ClientTest client = (await provider.ServiceAsync.PagingAsync(page, limit)).Last();

            client.Age  = age;
            client.Name = name;

            //[A]ct
            var        beforeSave = DateTime.Now;
            ClientTest result     = await provider.ServiceAsync.UpdateAsync(client);

            //[A]ssert
            Assert.Equal(client, result);
            Assert.True(result.Id > 0L, "After update, result does not contains an ID!");
            Assert.True(result.Uuid != Guid.Empty, "After update, result does not contains an Uuid!");
            Assert.True(result.Updated > beforeSave, "After update, result does not contains a valid auditable Updated date time!");
        }
        public async Task Service_Save_Successfully_Async(int age, string name)
        {
            //[A]rrange
            ClientTest client = new ClientTest
            {
                Age  = age,
                Name = name
            };

            //[A]ct
            var        beforeSave = DateTime.Now;
            ClientTest result     = await provider.ServiceAsync.SaveAsync(client);

            //[A]ssert
            Assert.Equal(client, result);
            Assert.True(result.Id > 0L, "After save, result does not contains an ID!");
            Assert.True(result.Uuid != Guid.Empty, "After save, result does not contains an Uuid!");
            Assert.True(result.Created > beforeSave, "After save, result does not contains a valid auditable Created date time!");
        }