예제 #1
0
        public void InitilizeTests()
        {
            this.dbContext = MockDbContext.GetContext();
            var mapper = MockAutomapper.GetMapper();

            this.service = new AdminSectionsService(dbContext, mapper);
        }
예제 #2
0
        public void InitilizeTests() // runs befor every test
        {
            this.dbContext = MockDbContext.GetContext();
            var mapper = MockAutomapper.GetMapper();

            this.service = new AdminCoursesService(dbContext, mapper);
        }
예제 #3
0
        public async Task Index_ShoudReturnAllUsersExceptCurrent() // !!!
        {
            var users = new[]
            {
                new User()
                {
                    Id = "111"
                },
                new User()
                {
                    Id = "222"
                },
                new User()
                {
                    Id = "333"
                },
                new User()
                {
                    Id = "444"
                },
            };

            var mockDbContext = MockDbContext.GetContext();

            mockDbContext.Users.AddRange(users);
            mockDbContext.SaveChanges();

            var mockUserStore = new Mock <IUserStore <User> >();

            //var mockUserManager = new Mock<UserManager<User>>();

            var mockUserManager = new Mock <UserManager <User> >(
                new Mock <IUserStore <User> >().Object, null, null, null, null, null, null, null, null);

            mockUserManager.Setup(um => um.GetUserAsync(null))
            .ReturnsAsync(users[1]);

            var controller = new UsersController(mockDbContext,
                                                 MockAutomapper.GetMapper(), mockUserManager.Object);

            //2. act:
            var result = await controller.Index() as ViewResult;

            //. assert:
            Assert.IsNotNull(result);
            var model = result.Model as IEnumerable <UserShortViewModel>;

            CollectionAssert.AreEqual(new[] { "111", "333", "444" },
                                      model.Select(u => u.Id).ToArray());
        }
예제 #4
0
 public void InitilizeTests()
 {
     this.dbContext = MockDbContext.GetContext();
     this.mapper    = MockAutomapper.GetMapper();
 }
 public void InitilizeTests() // runs befor every test
 {
     this.dbContext = MockDbContext.GetContext();
     this.mapper    = MockAutomapper.GetMapper();
 }