public ContextFixture()
        {
            testDbContextMock = new TestDbContextMock();

            // mock data created by https://barisates.github.io/pretend
            testDbContextMock.Users.AddRange(new dotnet_core_xunit.Entities.TestDb.Users[]
            {
                // for delete test
                new dotnet_core_xunit.Entities.TestDb.Users()
                {
                    Id         = 685349,
                    Email      = "0sgtsw",
                    Password   = "******",
                    FullName   = "mq8zp2",
                    CreateDate = DateTime.Now,
                    Status     = true,
                },
                // for get test
                new dotnet_core_xunit.Entities.TestDb.Users()
                {
                    Id         = 454673,
                    Email      = "0tec4e",
                    Password   = "******",
                    FullName   = "jqvlv2",
                    CreateDate = DateTime.Now,
                    Status     = true,
                }
            });
            testDbContextMock.SaveChanges();
        }
Пример #2
0
        public ControllerFixture()
        {
            #region Create mock/memory database

            testDbContextMock = new TestDbContextMock();

            // mock data created by https://barisates.github.io/pretend
            testDbContextMock.Users.AddRange(new dotnet_core_xunit.Entities.TestDb.Users[]
            {
                // for delete test
                new dotnet_core_xunit.Entities.TestDb.Users()
                {
                    Id         = 685349,
                    Email      = "0sgtsw",
                    Password   = "******",
                    FullName   = "mq8zp2",
                    CreateDate = DateTime.Now,
                    Status     = true,
                },
                // for get test
                new dotnet_core_xunit.Entities.TestDb.Users()
                {
                    Id         = 454673,
                    Email      = "0tec4e",
                    Password   = "******",
                    FullName   = "jqvlv2",
                    CreateDate = DateTime.Now,
                    Status     = true,
                }
            });

            testDbContextMock.SaveChanges();

            #endregion

            #region Mapper settings with original profiles.

            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });

            mapper = mappingConfig.CreateMapper();

            #endregion

            // Create UserService with Memory Database
            userService = new UserService(testDbContextMock, mapper);

            // Create Controller
            userController = new UserController(userService);
        }