示例#1
0
        public void A110_Validation_Null()
        {
            TestSetUp.CreateMock <IPersonData>();
            ExpectValidationException.Run(
                () => (new PersonManager()).CreateAsync(null),
                "Value is required.");

            ExpectValidationException.Run(
                () => (new PersonManager()).UpdateAsync(null, 1.ToGuid()),
                "Value is required.");
        }
示例#2
0
 public void A130_Validation_Invalid()
 {
     TestSetUp.CreateMock <IPersonData>();
     ExpectValidationException.Run(
         () => (new PersonManager()).CreateAsync(new Person()
     {
         FirstName = 'x'.ToLongString(), LastName = 'x'.ToLongString(), Birthday = DateTime.Now.AddDays(1), Gender = "X", EyeColor = "Y"
     }),
         "First Name must not exceed 50 characters in length.",
         "Last Name must not exceed 50 characters in length.",
         "Gender is invalid.",
         "Eye Color is invalid.",
         "Birthday must be less than or equal to Today.");
 }
示例#3
0
        public void Manager_TestE()
        {
            Console.WriteLine($"Start: {DateTime.Now.ToString("HH:mm:ss.ffffff")} [{System.Threading.Thread.CurrentThread.ManagedThreadId}]");
            TestSetUp.CreateMock <IPersonManager>().Setup(x => x.GetAsync(It.IsAny <Guid>())).ReturnsAsync(new Person {
                FirstName = "E"
            });
            System.Threading.Thread.Sleep(100);
            var v = AgentTester.Create <PersonAgent, Person>()
                    .ExpectStatusCode(System.Net.HttpStatusCode.OK)
                    .Run((a) => a.Agent.GetAsync(1.ToGuid())).Value;

            Console.WriteLine($"Stopping: {DateTime.Now.ToString("HH:mm:ss.ffffff")} [{System.Threading.Thread.CurrentThread.ManagedThreadId}]");
            Assert.AreEqual("E", v.FirstName);
        }
示例#4
0
        public async Task A110_Validation_Empty()
        {
            TestSetUp.CreateMock <IPersonData>();
            await ExpectValidationException.RunAsync(
                () => (new PersonManager()).CreateAsync(new Person()),
                "First Name is required.",
                "Last Name is required.",
                "Gender is required.",
                "Birthday is required.");

            await ExpectValidationException.RunAsync(
                () => (new PersonManager()).UpdateAsync(new Person(), 1.ToGuid()),
                "First Name is required.",
                "Last Name is required.",
                "Gender is required.",
                "Birthday is required.");
        }
示例#5
0
        public void ServiceAgent_TestF()
        {
            Console.WriteLine($"Start: {DateTime.Now.ToString("HH:mm:ss.ffffff")} [{System.Threading.Thread.CurrentThread.ManagedThreadId}]");
            var m = TestSetUp.CreateMock <IPersonServiceAgent>();

            m.Setup(x => x.GetAsync(It.IsAny <Guid>(), null)).ReturnsWebApiAgentResultAsync(new Person {
                FirstName = "F"
            });

            System.Threading.Thread.Sleep(100);
            Assert.AreSame(m.Object, Factory.Create <IPersonServiceAgent>());

            var v = new PersonAgent().GetAsync(1.ToGuid()).Result.Value;

            Console.WriteLine($"Stopping: {DateTime.Now.ToString("HH:mm:ss.ffffff")} [{System.Threading.Thread.CurrentThread.ManagedThreadId}]");
            Assert.AreEqual("F", v.FirstName);
        }