public void CheckEmployerToEditDetailsAreEqualLikeModel()
        {
            //Arrange
            Employer employer = new Employer()
            {
                Id   = 6,
                Name = "test",
                NIP  = "unit",
            };

            var config = new MapperConfiguration(c =>
            {
                c.AddProfile(new MappingProfile());
            });
            var mapper = config.CreateMapper();

            var mock = new Mock <IEmployerRepository>();

            mock.Setup(s => s.GetEmployer(6)).Returns(employer);

            var manager = new EmployerService(mapper, mock.Object);

            //Act
            var result = manager.GetEmployerForEdit(6);

            //Assert
            result.Should().NotBeNull();
            result.Id.Should().Equals(employer.Id);
            employer.Id = 7;
            result.Id.Should().Equals(employer.Id);
            result.Name.Should().Equals(employer.Name);
            result.NIP.Should().Equals(employer.NIP);
        }
Exemple #2
0
        public void CheckEmployerToEditDetailsAreEqualLikeModel()
        {
            //Arrange
            NewEmployerVm employerToAdd = new NewEmployerVm()
            {
                Id   = 1,
                Name = "test",
                NIP  = "Unit"
            };

            var config = new MapperConfiguration(c =>
            {
                c.AddProfile(new MappingProfile());
            });
            var mapper = config.CreateMapper();

            var options = new DbContextOptionsBuilder <Context>()
                          .UseInMemoryDatabase("UsersDirectoryMVC")
                          .Options;


            using (var context = new Context(options))
            {
                //Act
                var employerService = new EmployerService(mapper, new EmployerRepository(context));
                employerService.AddEmployer(employerToAdd);
                var result = employerService.GetEmployerForEdit(1);

                //Assert
                result.Should().NotBeNull();
                result.Should().Equals(employerToAdd);
                context.Employers.FirstOrDefaultAsync(e => e.Id == result.Id).Should().NotBeNull();
            }
        }