Exemple #1
0
        public void HandleValid()
        {
            var q = new ClientQuery()
            {
                GivenName = "Paul",
                SurName   = "Glenn",
            };

            var res = _handler.Handle(q);

            Assert.AreEqual("Paul", res.GivenName);
            Assert.AreEqual("Glenn", res.SurName);
        }
Exemple #2
0
        public void CachedQueryTest()
        {
            var cli = new Client()
            {
                GivenName = "Hans", MiddleName = "P.", SurName = "Anderson"
            };

            var q = new ClientQuery()
            {
                GivenName = "Hans", SurName = "Anderson"
            };

            _cache.Set(q.CacheKey, cli);
            var res = _handler.Handle(q);

            Assert.AreSame(cli, res);
        }
Exemple #3
0
        public void ValidateObject_IsValid()
        {
            var q = new ClientQuery()
            {
                GivenName = "Paul",
                SurName   = "Glenn",
                ExtParams = new ExtParams()
                {
                    RefererName = "Hanso"
                }
            };

            var res = _handler.Handle(q);

            Assert.AreEqual("Paul", res.GivenName);
            Assert.AreEqual("Glenn", res.SurName);
        }
Exemple #4
0
        public void RepeatQueryTest()
        {
            var q = new ClientQuery()
            {
                GivenName = "Hans", SurName = "Anderson"
            };
            var res = _handler.Handle(q);

            Assert.AreEqual("Hans", res.GivenName);
            Assert.AreEqual("Anderson", res.SurName);

            var res2 = _handler.Handle(q);

            Assert.AreEqual("Hans", res2.GivenName);
            Assert.AreEqual("Anderson", res2.SurName);

            Assert.AreSame(res, res2);
        }
Exemple #5
0
        public void ValidateInvalid()
        {
            var q = new ClientQuery()
            {
                SurName = "Glenn"
            };

            try
            {
                _handler.Handle(q);
            }
            catch (AggregateException ex)
            {
                if (ex.InnerExceptions.Count != 1 || !(ex.InnerExceptions[0] is ValidationException) || !ex.InnerExceptions[0].Message.Contains("GivenName"))
                {
                    Assert.Fail();
                }
            }
        }
Exemple #6
0
        public void ValidateObject_IsInvalid()
        {
            var q = new ClientQuery()
            {
                GivenName = "Paul",
                SurName   = "Glenn",
                ExtParams = new ExtParams()
                {
                }
            };

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