protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes, Assembly.GetExecutingAssembly().GetName().Name); BundleConfigJs.RegisterBundles(BundleTable.Bundles); BundleConfigCss.RegisterBundles(BundleTable.Bundles); MapperConfig.ConfigureAutomapper(); IocContainer.Setup(Assembly.GetExecutingAssembly().GetName().Name); }
public void GetById_UserId_ReturnsUserDto() { MapperConfig.ConfigureAutomapper(); var id = 666; var user = new User { Id = id }; A.CallTo(() => _repository.GetById <User>(id)).Returns(user); Assert.Equal(user.Id, _userService.GetById(id).UserId); }
public void Add_UserDto_MustHaveHappened() { MapperConfig.ConfigureAutomapper(); var id = 666; var user = new UserDto { UserId = id }; _userService.Add(user); A.CallTo(() => _repository.Add <User>(_mapper.Map <User>(user))).MustHaveHappenedOnceExactly(); }
public void Update_UserDto_MustHaveHappened() { MapperConfig.ConfigureAutomapper(); var id = 666; var user = new UserDto { UserId = id }; _userService.Update(user); A.CallTo(_repository).Where(call => call.Method.Name == nameof(_repository.Update) && call.Method.IsGenericMethod) .WithVoidReturnType().MustHaveHappenedOnceExactly(); A.CallTo(() => _repository.SaveChanges()).MustHaveHappenedOnceExactly(); }
public void GetAll_Nothing_CollectionOfUserDto() { MapperConfig.ConfigureAutomapper(); IEnumerable <User> users = new[] { new User { Id = 1 }, new User { Id = 2 } }; var expectedIds = new[] { 1, 2 }; A.CallTo(() => _repository.GetAll <User>()).Returns(users); var testUsers = _userService.GetAll() as List <UserDto>; Assert.Equal(expectedIds.Length, testUsers.Count); for (int i = 0; i < expectedIds.Length; i++) { Assert.Equal(expectedIds[i], testUsers[i].UserId); } }
public void GetListOfBirthday_Nothing_ListDto() { MapperConfig.ConfigureAutomapper(); IEnumerable <User> users = new[] { new User { Id = 1, BirthDate = DateTime.Today } }; var expectedIds = new[] { 1 }; Expression <Func <User, bool> > filter = user => user.BirthDate.Value.Date.Day == DateTime.Today.Day && user.BirthDate.Value.Date.Month == DateTime.Today.Month; A.CallTo(() => _repository.Get <User>(filter, null)).Returns(users); var lisOfUsers = _userService.GetListOfBirthdays() as List <UserDto>; Assert.Equal(expectedIds.Length, lisOfUsers.Count); for (int i = 0; i < expectedIds.Length; i++) { Assert.Equal(expectedIds[i], lisOfUsers[i].UserId); } }
protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); MapperConfig.ConfigureAutomapper(); ApiIocContainer.ConfigureWindsor(Assembly.GetExecutingAssembly().GetName().Name, GlobalConfiguration.Configuration); }
protected BaseTest() { this.dbContext = new MockedUisDbContext(); this.SeedData(); MapperConfig.ConfigureAutomapper(); }