コード例 #1
0
ファイル: ChangeEntityTest.cs プロジェクト: megafetis/ConveyR
        public async Task ChangeTestEntityPostWithprocessTest()
        {
            var entity = new TestEntity();
            var payload = new ChangeTestEntityPayload()
            {
                Name = "Name 1",
                Description = "Description 1"
            };

            Assert.Null(entity.Id);
            Assert.Null(entity.Name);
            Assert.Null(entity.Description);
            var changeContext = new TestEntitiesStore(_conveyor);

            await changeContext.ChangeEntity(entity, payload);

            Assert.AreEqual("Name 1", entity.Name);
            Assert.NotNull(entity.Id);
            Assert.AreEqual("Description 1", entity.Description);

            Assert.Null(entity.Timestamp);

            await changeContext.AfterChangeEntity(entity, payload);

            Assert.NotNull(entity.Timestamp);
        }
コード例 #2
0
ファイル: ChangeEntityTest.cs プロジェクト: megafetis/ConveyR
        public async Task ChangeTestEntityWithRollbackTest()
        {
            var entity = new TestEntity();
            var payload = new ChangeTestEntityPayload()
            {
                //Name = "Name 1",
                Description = "Description 1"
            };

            Assert.Null(entity.Id);
            Assert.Null(entity.Name);
            Assert.Null(entity.Description);
            var changeContext = new TestEntitiesStore(_conveyor);

            try
            {
                await changeContext.ChangeEntity(entity, payload);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                await changeContext.RollbackChangeEntitiy(entity, payload);
                Assert.Greater(entity.FailCount,0);
                return;
            }

            Assert.AreEqual("Name 1", entity.Name);
            Assert.NotNull(entity.Id);
            Assert.AreEqual("Description 1", entity.Description);

            Assert.Null(entity.Timestamp);

            await changeContext.AfterChangeEntity(entity, payload);

            Assert.NotNull(entity.Timestamp);
        }