Exemplo n.º 1
0
        public void GetPersonFail(string term)
        {
            GetPersonQuery query = new GetPersonQuery(term);

            query.Execute();
            GetPersonResult result = query.GetResult() as GetPersonResult;

            Assert.IsTrue(result.Succeeded);
            Assert.AreEqual(0, result.Persons.Count);
        }
Exemplo n.º 2
0
        public void GetPerson(string term)
        {
            GetPersonQuery query = new GetPersonQuery(term);

            query.Execute();
            GetPersonResult result = query.GetResult() as GetPersonResult;

            Assert.IsTrue(result.Succeeded);
            Assert.AreEqual(1, result.Persons.Count);
            Assert.AreEqual(1, result.Persons[0].Id);
            Assert.AreEqual("Avocado", result.Persons[0].Name);
            Assert.AreEqual("Brazil", result.Persons[0].Nationality);
        }
Exemplo n.º 3
0
        public void ListPersons()
        {
            GetPersonQuery query = new GetPersonQuery();

            query.Execute();
            GetPersonResult result = query.GetResult() as GetPersonResult;

            Assert.AreEqual(result.Persons.Count, 3);
            Assert.AreEqual(result.Persons[0].Name, "Alfred");
            Assert.AreEqual(result.Persons[0].Nationality, "Africa");
            Assert.AreEqual(result.Persons[1].Name, "Billy");
            Assert.AreEqual(result.Persons[1].Nationality, "Botswana");
            Assert.AreEqual(result.Persons[2].Name, "Chad");
            Assert.AreEqual(result.Persons[2].Nationality, "Chad");
        }
Exemplo n.º 4
0
        public ActionResult <List <Person> > Get(string term = "")
        {
            var query = new GetPersonQuery(term);

            query.Execute();
            if (!query.GetResult().Succeeded)
            {
                return(BadRequest("The request for Persons failed."));
            }

            var result = query.GetResult() as GetPersonResult;

            if (result.Persons.Count == 0)
            {
                return(NoContent());
            }

            return(Ok(result.Persons));
        }
        public void DeletePerson()
        {
            DeletePersonCommand dpc = new DeletePersonCommand(1);

            dpc.Execute();
            DeletePersonResult dpr = dpc.GetResult() as DeletePersonResult;

            Assert.IsTrue(dpr.Succeeded);
            Assert.AreEqual(1, dpr.Person.Id);
            Assert.AreEqual("Boris", dpr.Person.Name);
            Assert.AreEqual("Britian", dpr.Person.Nationality);

            GetPersonQuery gpq = new GetPersonQuery("Boris");

            gpq.Execute();
            GetPersonResult gpr = gpq.GetResult() as GetPersonResult;

            Assert.IsTrue(gpr.Succeeded);
            Assert.AreEqual(0, gpr.Persons.Count);
        }
Exemplo n.º 6
0
        public void UpdatePerson()
        {
            Command unc = new UpdatePersonCommand(1, "Gazza", "Gurder");

            unc.Execute();
            UpdatePersonResult unr = unc.GetResult() as UpdatePersonResult;

            Assert.IsTrue(unr.Succeeded);
            Assert.AreEqual("Gazza", unr.Person.Name);

            Command gpq = new GetPersonQuery("1");

            gpq.Execute();
            GetPersonResult gpr = gpq.GetResult() as GetPersonResult;

            Assert.IsTrue(gpr.Succeeded);
            Assert.AreEqual(1, gpr.Persons.Count);
            Assert.AreEqual("Gazza", gpr.Persons[0].Name);
            Assert.AreEqual("Gurder", gpr.Persons[0].Nationality);
        }