public void HandleInvalid()
        {
            var cmd = new AddClientCommand()
            {
                SurName = "Glenn"
            };

            _handler.Handle(cmd);
        }
예제 #2
0
        public void HandleValid()
        {
            var cmd = new AddClientCommand()
            {
                GivenName = "Paul",
                SurName   = "Glenn",
            };

            _handler.Handle(cmd);
        }
예제 #3
0
        public void ValidateObject_IsValid()
        {
            var cmd = new AddClientCommand()
            {
                GivenName = "Paul",
                SurName   = "Glenn",
                Address   = new Address2()
                {
                    City = "London", Street = "Padington", House = 7, Flat = 11
                }
            };

            _handler.Handle(cmd);
        }
        public void HandleValid()
        {
            var cmd = new AddClientCommand()
            {
                GivenName = "Paul",
                SurName   = "Glenn",
            };

            _handler.Handle(cmd);

            var ctx = (ClientDataContext)_handler.DbContext;

            Assert.AreEqual(1, ctx.DataSource.Count);
            Assert.AreEqual("Paul", ctx.DataSource[0].GivenName);
            Assert.AreEqual("Glenn", ctx.DataSource[0].SurName);
        }
예제 #5
0
        public void HandleValid()
        {
            var cmd = new AddClientCommand()
            {
                GivenName = "Paul",
                SurName   = "Glenn",
            };

            _handler.Handle(cmd);

            var ctx = (ClientDataContext)_handler.DbContext;

            Assert.AreEqual(1, ctx.BeginCount);
            Assert.AreEqual(1, ctx.CommitCount);
            Assert.AreEqual(0, ctx.RollbackCount);
        }
예제 #6
0
        public void ValidateInvalid()
        {
            var cmd = new AddClientCommand()
            {
                SurName = "Glenn"
            };

            try
            {
                _handler.Handle(cmd);
            }
            catch (AggregateException ex)
            {
                if (ex.InnerExceptions.Count != 1 || !(ex.InnerExceptions[0] is ValidationException) || !ex.InnerExceptions[0].Message.Contains("GivenName"))
                {
                    Assert.Fail();
                }
            }
        }
예제 #7
0
        public void HandleInvalid()
        {
            var cmd = new AddClientCommand()
            {
                SurName = "Glenn"
            };

            try
            {
                _handler.Handle(cmd);
            }
            catch (AggregateException ex)
            {
            }

            var ctx = (ClientDataContext)_handler.DbContext;

            Assert.AreEqual(1, ctx.BeginCount);
            Assert.AreEqual(0, ctx.CommitCount);
            Assert.AreEqual(1, ctx.RollbackCount);
        }
예제 #8
0
        public void ValidateObject_IsInvalid()
        {
            var q = new AddClientCommand()
            {
                GivenName = "Paul",
                SurName   = "Glenn",
                Address   = new Address2()
                {
                    City = "London", Street = "Padington", House = 7
                }
            };

            try
            {
                _handler.Handle(q);
            }
            catch (AggregateException ex)
            {
                if (ex.InnerExceptions.Count != 1 || !(ex.InnerExceptions[0] is ValidationException) || !ex.InnerExceptions[0].Message.Contains("Flat"))
                {
                    Assert.Fail();
                }
            }
        }