Exemple #1
0
        public void DeleteTests()
        {
            // ARRANGE
            var controller = new PeopleSearch.Web.Controllers.API.PersonController(_personRepository);

            // ACT
            controller.Delete(1);

            // ASSERT
            _persons.ToList().Any(p => p.Id == 1).Should().BeFalse();
            _mockContext.Verify(x => x.SaveChanges());
        }
Exemple #2
0
        public void SearchTests()
        {
            // ARRANGE
            var controller = new PeopleSearch.Web.Controllers.API.PersonController(_personRepository);

            // ACT
            var results      = controller.Get("ast2");
            var deserialized = JsonConvert.DeserializeObject <PersonModel[]>(results);

            // ASSERT
            deserialized.Should().NotBeNull();
            deserialized.Length.Should().Be(11);
        }
Exemple #3
0
        public void GetTests()
        {
            // ARRANGE
            var controller = new PeopleSearch.Web.Controllers.API.PersonController(_personRepository);

            // ACT
            var result = controller.Get(5);

            // ASSERT
            result.Should().NotBeNullOrEmpty();
            result.Should().Contain("First5");
            // todo: the linkage to the inerests/image in the mock data context isn't working
        }
Exemple #4
0
        public void PostTests()
        {
            // ARRANGE
            var controller = new PeopleSearch.Web.Controllers.API.PersonController(_personRepository);
            var dtoPerson  = new BigCompany.Contracts.Person()
            {
                DateOfBirth = new DateTime(1985, 5, 22),
                FirstName   = "UniqueString",
                LastName    = "Last",
                ImageBase64 = "test",
                Interests   = new[] { "Snowboarding", "Skydiving", "Faberge Eggs" }
            };

            // ACT
            controller.Post(dtoPerson);

            // ASSERT
            _persons.ToList().Any(x => x.FirstName == "UniqueString").Should().BeTrue();
            _mockContext.Verify(x => x.SaveChanges());
        }