Esempio n. 1
0
      public async void SellArmor_ShouldIncreaseUserCoins()
      {
          var users = new[]
          {
              new User()
              {
                  Id = "222"
              },
              new User()
              {
                  Id = "333"
              },
              new User()
              {
                  Id = "444"
              }
          };

          this.dbContext = MockDbContext.GetContext();



          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.armorService     = new ArmorDataService(dbContext, this.service, MockAutoMapper.GetAutoMapper(), mockUserManager.Object);
          this.weaponService    = new WeaponDataService(dbContext, this.service, MockAutoMapper.GetAutoMapper(), mockUserManager.Object);
          this.dbContextService = new DbContextService(dbContext, this.service, MockAutoMapper.GetAutoMapper(), mockUserManager.Object);

          var controller = new StoreController(mockUserManager.Object, this.weaponService, this.armorService, this.dbContextService, MockAutoMapper.GetAutoMapper());

          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 = 0
          };
          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.SellArmorPost(1);

          Assert.AreEqual(60, newwwwUser.Coins);
      }
Esempio n. 2
0
 public void InitializeTests()
 {
     this.dbContext = MockDbContext.GetContext();
     this.mapper    = MockAutoMapper.GetAutoMapper();
 }
Esempio n. 3
0
 public void InitializeTests()
 {
     this.mapper     = MockAutoMapper.GetAutoMapper();
     this.dbContext  = MockDbContext.GetContext();
     this.controller = new ProcessorsController(dbContext, mapper);
 }
Esempio n. 4
0
 public void InitializeTests()
 {
     this.dbContext = MockDbContext.GetContext();
     this.service   = new InterviewerTestsService(dbContext, MockAutoMapper.GetAutoMapper());
 }