public void InitializeTests() { this.context = MockDbContext.GetContext(); this.service = new AdminRewardsService(context, MockAutoMapper.GetMapper()); CreateInitialEvents(); }
public MunroControllerTest() { var dataContext = new MunroDataContext(); var service = new MunroService(dataContext, MockAutoMapper.CreateMockMapper()); controller = new MunrosController(service); }
public void InitializeTests() { this.dbContext = MockDbContext.GetDbContext(); var mapper = MockAutoMapper.GetMapper(); this.service = new AdminVideosService(dbContext, mapper); }
public void InitializeTests() { this.dbContext = MockDbContext.GetContext(); this.interviews = new AdminInterviewService(dbContext, MockAutoMapper.GetAutoMapper()); this.applicants = new AdminApplicantService(dbContext, MockAutoMapper.GetAutoMapper()); this.tests = new InterviewerTestsService(dbContext, MockAutoMapper.GetAutoMapper()); }
public void InitializeTests() { this.dbContext = MockDbContext.GetContext(); this.mapper = MockAutoMapper.GetAutoMapper(); this.postService = new PostService(dbContext, mapper); this.postController = new PostsController(postService, mapper); }
public void Initialize() { this.dbContext = MockDbContext.GetContext(); var mapper = MockAutoMapper.GetMapper(); this.categories = new CategoryService(this.dbContext, mapper); }
public AdminProductServiceTest() { this.context = MockDbContext.GetContext(); this.mapper = MockAutoMapper.GetAutoMapper(); this.dropDownService = new DropDownListService(this.context, this.mapper); this.productService = new ProductService(this.context, this.mapper); this.adminProductService = new AdminProductService(this.context, this.mapper, this.productService, this.dropDownService); }
public void InitializeTests() { this.dbContext = MockDbContext.GetDbContext(); var mapper = MockAutoMapper.GetMapper(); this.townsService = new TownsService(dbContext, mapper); this.companiesService = new CompaniesService(dbContext, mapper, townsService); }
public void InitializeTests() { this.dbContext = MockDbContext.GetContext(); this.mapper = MockAutoMapper.GetAutoMapper(); this.propertyService = new PropertyService(dbContext, mapper); this.mockedConfig = new Mock <IConfiguration>(); this.propertiesController = new PropertiesController(propertyService, mapper); }
public void InitializeTests() { this.dbContext = MockDbContext.GetContext(); this.mapper = MockAutoMapper.GetAutoMapper(); this.userManager = this.TestUserManager <User>(); this.userService = new UserService(dbContext, mapper, userManager); this.mockedConfig = new Mock <IConfiguration>(); this.usersController = new UsersController(userService, mapper, userManager, dbContext); }
public virtual void InitializeTests() { this.dbContext = MockDbContext.GetContext(); var userManager = MockUserManager.GetUserManager(dbContext); this.service = new UserProgramsService( dbContext, MockAutoMapper.GetAutoMapper(), userManager); }
public void InitializeTests() { var options = new DbContextOptionsBuilder <PCBuilderContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; this.mapper = MockAutoMapper.GetAutoMapper(); this.dbContext = new PCBuilderContext(options); this.controller = new PowerSuppliesController(dbContext, mapper); }
public virtual void InitializeTests() { this.dbContext = MockDbContext.GetContext(); var userManager = MockUserManager.GetUserManager(dbContext); var mockUserProgramService = new Mock <IUserProgramsService>(); mockUserProgramService.Setup(opt => opt.GetDefaulttUserProgram(MockUserManager.testUserId)) .ReturnsAsync(this.GetOrCreateTestProgram); var mockTrainerProgramService = new Mock <ITrainersProgramsService>(); var mockTraininService = new Mock <ITrainingsService>(); mockTraininService .Setup(opt => opt.GetTrainingAsync(testTrainingId, MockUserManager.testUsername)) .ReturnsAsync(() => { var training = this.dbContext.Trainings.FirstOrDefault(); if (training == null) { throw new Exception(); } return(training); }); var mockMealService = new Mock <IMealsService>(); mockMealService .Setup(opt => opt.GetMealAsync(testMealId, MockUserManager.testUsername)) .ReturnsAsync(() => { var meal = this.dbContext.Meals.FirstOrDefault(); if (meal == null) { throw new Exception(); } this.dbContext.SaveChanges(); return(meal); }); this.service = new DaysService( dbContext, MockAutoMapper.GetAutoMapper(), userManager, mockUserProgramService.Object, mockTrainerProgramService.Object, mockTraininService.Object, mockMealService.Object); }
public virtual void InitializeTests() { this.dbContext = MockDbContext.GetContext(); var userManager = MockUserManager.GetUserManager(dbContext); var exercisesService = new Mock <IExercisesService>(); this.service = new TrainingsService( dbContext, MockAutoMapper.GetAutoMapper(), userManager, exercisesService.Object); }
public void InitializeTests() { this._dbContext = MockDbContext.GetContext(); this._mapper = MockAutoMapper.GetAutoMapper(); this._service = new AdminManufacturersService(this._dbContext, this._mapper); this._dbContext.Manufacturers.Add(new Manufacturer() { Id = 1, Name = string.Format(TestsConstants.Manufacturer, 1), LogoUrl = string.Format(TestsConstants.Logo, 1) }); this._dbContext.SaveChanges(); }
public void InitializeTests() { this.dbContext = MockDbContext.GetContext(); this.mapper = MockAutoMapper.GetAutoMapper(); this.service = new AdminTeamsService(this.dbContext, this.mapper); this.dbContext.Teams.Add(new Team() { Id = 1, Name = string.Format(TestsConstants.Team, 1), LogoUrl = string.Format(TestsConstants.Logo, 1) }); this.dbContext.SaveChanges(); }
public void InitializeTests() { this.mapper = MockAutoMapper.GetAutoMapper(); this.dbContext = MockDbContext.GetContext(); this.userManager = new UserManager <User>(new UserStore <User>(dbContext), null, null, null, null, null, null, null, null); this.controller = new BuildsController(dbContext, mapper, userManager); var users = new[] { new User() { Id = "111" }, new User() { Id = "222" }, new User() { Id = "333" }, new User() { Id = "444" } }; var mockUserStore = new Mock <IUserStore <User> >(); var mockUserManager = new Mock <UserManager <User> >( mockUserStore.Object, null, null, null, null, null, null, null, null); mockUserManager.Setup(um => um.GetUserAsync(null)) .ReturnsAsync(users[1]); controller.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Role, "User") })) } }; var tempData = new TempDataDictionary(controller.HttpContext, Mock.Of <ITempDataProvider>()); controller.TempData = tempData; }
public void InitializeTests() { this.mapper = MockAutoMapper.GetAutoMapper(); this.db = MockDbContext.GetTestDb(); this.service = new ParticipantRepliesService(this.db, this.mapper); var testQuestion = new Question() { Id = 1, Content = "First test", EventId = 1 }; db.Questions.Add(testQuestion); db.SaveChanges(); }
public void InitializeTests() { this.db = MockDbContext.GetTestDb(); this.mapper = MockAutoMapper.GetAutoMapper(); var question = new Question() { Id = 1, AuthorName = "Pesho", EventId = 1, IsArchived = true }; this.db.Questions.Add(question); this.db.SaveChanges(); this.service = new ManagerQuestionsService(this.db, this.mapper); }
public void InitializeTests() { this._dbContext = MockDbContext.GetContext(); this._mapper = MockAutoMapper.GetAutoMapper(); this._service = new AdminProductsService(this._dbContext, this._mapper); this._dbContext.Manufacturers.Add(new Manufacturer() { Id = 1, Name = string.Format(TestsConstants.Manufacturer, 1) }); this._dbContext.SaveChanges(); this._dbContext.Products.Add(new Product() { Id = 1, Name = string.Format(TestsConstants.Product, 1), Type = string.Format(TestsConstants.Type, 1), ManufacturerId = 1 }); this._dbContext.SaveChanges(); }
public void InitializeTests() { this.dbContext = MockDbContext.GetContext(); this.mapper = MockAutoMapper.GetAutoMapper(); this.service = new AdminProductsService(this.dbContext, this.mapper); this.dbContext.Teams.Add(new Team() { Id = 1, Name = string.Format(TestsConstants.Team, 1) }); this.dbContext.SaveChanges(); this.dbContext.Products.Add(new Product() { Id = 1, Title = string.Format(TestsConstants.Product, 1), Brand = string.Format(TestsConstants.Brand, 1), TeamId = 1 }); this.dbContext.SaveChanges(); }
public void EditingRobot_ShouldEditRobotName() { var users = new[] { new User() { Id = "111" }, new User() { Id = "222" }, new User() { Id = "333" }, new User() { Id = "444" } }; var mockUserStore = new Mock <IUserStore <User> >(); var mockUserManager = new Mock <UserManager <User> >( mockUserStore.Object, null, null, null, null, null, null, null, null); mockUserManager.Setup(um => um.GetUserAsync(null)) .ReturnsAsync(users[1]); this.dbContext = MockDbContext.GetContext(); this.service = new RobotDataService(dbContext, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); this.armorService = new ArmorDataService(dbContext, this.service, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); this.weaponService = new WeaponDataService(dbContext, this.service, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); var controller = new RobotController(mockUserManager.Object, MockAutoMapper.GetAutoMapper(), this.service, this.weaponService, this.armorService); controller.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Role, "Admin") })) } }; var user2 = controller.ControllerContext.HttpContext.User; var robot = new Models.Robots.Robot() { Id = 1, BaseHealth = 1000, CurrentHealth = 1000, BaseDamage = 100, Type = "Fire", ImageUrl = "https://i.ytimg.com/vi/Rrb4jW_uJxE/hqdefault.jpg" }; this.dbContext.Robots.Add(robot); this.dbContext.SaveChanges(); var updateNameBindingModel = new UpdateNameBindingModel() { Name = "Edited" }; var result = controller.Edit(robot.Id, updateNameBindingModel); //service.CreateRobotAsync(user2, robot); Assert.AreEqual("Edited", dbContext.Robots.First().Name); }
public void UnequipArmor_ShouldRemoveArmorFromRobot() { var users = new[] { new User() { Id = "111" }, new User() { Id = "222" }, new User() { Id = "333" }, new User() { Id = "444" } }; var mockUserStore = new Mock <IUserStore <User> >(); var mockUserManager = new Mock <UserManager <User> >( mockUserStore.Object, null, null, null, null, null, null, null, null); mockUserManager.Setup(um => um.GetUserAsync(null)) .ReturnsAsync(users[1]); this.dbContext = MockDbContext.GetContext(); this.service = new RobotDataService(dbContext, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); this.armorService = new ArmorDataService(dbContext, this.service, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); this.weaponService = new WeaponDataService(dbContext, this.service, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); var controller = new RobotController(mockUserManager.Object, MockAutoMapper.GetAutoMapper(), this.service, this.weaponService, this.armorService); controller.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Role, "Admin") })) } }; var user2 = controller.ControllerContext.HttpContext.User; var robot = new Models.Robots.Robot() { Id = 1, BaseHealth = 1000, CurrentHealth = 1000, BaseDamage = 100, Type = "Fire", ImageUrl = "https://i.ytimg.com/vi/Rrb4jW_uJxE/hqdefault.jpg" }; var armor = new Models.Items.Armor() { Name = "mechoo", ArmorPoints = 101, DurabilityLossAmount = 15, ImageUrl = "kk", Price = 101 }; dbContext.Robots.Add(robot); dbContext.Armors.Add(armor); robot.Armors.Add(armor); this.dbContext.SaveChanges(); var result = controller.UnequipArmor(robot.Id, armor.Id); this.dbContext.SaveChanges(); Assert.AreEqual(0, robot.Armors.Count()); }
public void InitializeTests() { this.dbContext = MockDbContext.GetContext(); this.service = new AdminCommentsService(this.dbContext, MockAutoMapper.GetAutoMapper()); }
public void InitializeTests() { this.dbContext = MockDbContext.GetDbContext(); this.mapper = MockAutoMapper.GetAutoMapper(); }
public void Initialize() { this.dbContext = MockDbContext.GetDbContext(); this.genreService = new ModeratorGenreService(this.dbContext, MockAutoMapper.GetMapper()); }
public void TestsSetup() { this.DbContext = MockDbContext.GetDbContext(); this.Mapper = MockAutoMapper.GetMapper(); }
public async void RepairCenter_ShouldRepairArmor() { var users = new[] { new User() { Id = "222" }, new User() { Id = "333" }, new User() { Id = "444" } }; //setup your expectations here var mockUserStore = new Mock <IUserStore <User> >(); var mockUserManager = new Mock <UserManager <User> >( mockUserStore.Object, null, null, null, null, null, null, null, null); mockUserManager.Setup(um => um.GetUserAsync(null)) .ReturnsAsync(users[1]); this.dbContext = MockDbContext.GetContext(); this.service = new RobotDataService(dbContext, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); this.armorService = new ArmorDataService(dbContext, this.service, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); this.weaponService = new WeaponDataService(dbContext, this.service, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); this.creepService = new CreepDataService(dbContext, this.service, MockAutoMapper.GetAutoMapper()); this.dbContextService = new DbContextService(dbContext, this.service, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); this.userService = new UserDataService(dbContext, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); var controller = new RepairCenterController(mockUserManager.Object, MockAutoMapper.GetAutoMapper(), dbContextService, this.service, armorService, weaponService, userService); controller.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Role, "Admin") })) } }; var tempData = new TempDataDictionary(controller.HttpContext, Mock.Of <ITempDataProvider>()); controller.TempData = tempData; var newwwwUser = new User() { Id = "1", Coins = 251 }; var armor = new ArmorDetailsViewModel() { Id = 1, Name = "mechoo", ArmorPoints = 101, CurrentArmor = 50, Durability = 50, ImageUrl = "kk", Price = 120, }; dbContext.Users.Add(newwwwUser); var actualArmor = new Armor() { Id = 1, Name = "mechoo", ArmorPoints = 101, Durability = 50, ImageUrl = "kk", Price = 120, UserId = "1", User = newwwwUser }; this.dbContext.Armors.Add(actualArmor); this.dbContext.SaveChanges(); await controller.Repair(1, "ArmorRepairViewModel"); Assert.AreEqual(1, newwwwUser.Coins); }
public MunroServiceTest() { testMapper = MockAutoMapper.CreateMockMapper(); }
public async void Fight_ShouldDecreaseRobotPoints() { var users = new[] { new User() { Id = "111" }, new User() { Id = "222" }, new User() { Id = "333" }, new User() { Id = "444" } }; var mockUserStore = new Mock <IUserStore <User> >(); var mockUserManager = new Mock <UserManager <User> >( mockUserStore.Object, null, null, null, null, null, null, null, null); mockUserManager.Setup(um => um.GetUserAsync(null)) .ReturnsAsync(users[1]); this.dbContext = MockDbContext.GetContext(); this.service = new RobotDataService(dbContext, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); this.armorService = new ArmorDataService(dbContext, this.service, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); this.weaponService = new WeaponDataService(dbContext, this.service, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); this.creepService = new CreepDataService(dbContext, this.service, MockAutoMapper.GetAutoMapper()); this.dbContextService = new DbContextService(dbContext, this.service, MockAutoMapper.GetAutoMapper(), mockUserManager.Object); var robot = new Models.Robots.Robot() { Id = 1, BaseHealth = 1000, CurrentHealth = 1000, BaseDamage = 100, Type = "Fire", ImageUrl = "https://i.ytimg.com/vi/Rrb4jW_uJxE/hqdefault.jpg" }; var creep = new Creep() { Id = 1, Name = "aaaa", Type = "Fire", Health = 1000, Damage = 100, Bounty = 10, ImageUrl = "1" }; var controller = new BattleController ( mockUserManager.Object, MockAutoMapper.GetAutoMapper(), this.service, this.creepService, this.dbContextService ); controller.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Role, "Admin") })) } }; this.dbContext.Robots.Add(robot); this.dbContext.Creeps.Add(creep); this.dbContext.SaveChanges(); await controller.Fight(robot.Id, creep.Id); Assert.AreEqual(0, robot.CurrentHealth); }