Esempio n. 1
0
        public void ShouldReturnCorrectResultWithCorrectModel()
        {
            // Arrange
            var db = Tests.GetDatabase();

            var missingPeopleData = this.GetMissingPeopleData();

            db.AddRange(missingPeopleData);

            db.SaveChanges();

            var missingPeopleService = new MissingPeopleService(db);

            // Act
            var result = missingPeopleService.All().OrderBy(r => r.Id);

            // Assert
            result
            .Should().AllBeOfType <MissingPeopleListingServiceModel>()
            .And.HaveCount(2);

            result
            .Should().Match(r =>
                            r.ElementAt(0).Id == 1 &&
                            r.ElementAt(1).Id == 2);
        }
Esempio n. 2
0
        public void ShouldReturnTrueIfPersonExists()
        {
            // Arrange
            var db = Tests.GetDatabase();

            var missingPeopleData = this.GetMissingPeopleData();

            db.AddRange(missingPeopleData);

            db.SaveChanges();

            var missingPeopleService = new MissingPeopleService(db);

            // Act
            var result = missingPeopleService.IsPersonExisting(1);

            // Assert
            result
            .Should().BeTrue();
        }
Esempio n. 3
0
        public void ShouldReturnTwoAsMethodCountIsInvoked()
        {
            // Arrange
            var db = Tests.GetDatabase();

            var missingPeopleData = this.GetMissingPeopleData();

            db.AddRange(missingPeopleData);

            db.SaveChanges();

            var missingPeopleService = new MissingPeopleService(db);

            // Act
            var result = missingPeopleService.Total();

            // Assert
            result
            .Should().Be(2);
        }
Esempio n. 4
0
        public void ShouldGetTheCorrectResultForSearchingCriteria()
        {
            // Arrange
            var db = Tests.GetDatabase();

            var missingPeopleData = this.GetMissingPeopleData();

            db.AddRange(missingPeopleData);

            db.SaveChanges();

            var missingPeopleService = new MissingPeopleService(db);

            // Act
            var searchName = "Pesho";
            var result     = missingPeopleService.SearchByComponents(false, 0, false, Gender.Male, searchName, null, null, 0);

            // Assert
            result
            .Should().HaveCount(1)
            .And.Match(r => r.ElementAt(0).FirstName == searchName);
        }
Esempio n. 5
0
        public void ShouldReturnCorrectPersonDetails()
        {
            // Arrange
            var db = Tests.GetDatabase();

            var missingPeopleData = this.GetMissingPeopleData();

            db.AddRange(missingPeopleData);

            db.SaveChanges();

            var missingPeopleService = new MissingPeopleService(db);

            // Act
            var resultPesho = missingPeopleService.GetPerson(1);
            var resultIvan  = missingPeopleService.GetPerson(2);

            // Assert
            resultPesho.FirstName
            .Should().Match(r => r.Equals("Pesho"));

            resultIvan.FirstName
            .Should().Match(r => r.Equals("Ivan"));
        }