Example #1
0
        public async Task NotificationRule_Edit_Test_Valid_ID()
        {
            //Arrange
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
            {
                new Claim(ClaimTypes.Name, "example name"),
                new Claim(ClaimTypes.NameIdentifier, "1"),
                new Claim("custom-claim", "example claim value"),
            }, "mock"));

            var optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            optionsBuilder.UseInMemoryDatabase(databaseName: "CommerceTestDB");
            var _dbContext = new ApplicationDbContext(optionsBuilder.Options);

            var controller = new NotificationController(_dbContext);

            controller.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext()
                {
                    User = user
                }
            };

            //Act
            var result = await controller.Edit(1);

            //Assert
            Assert.NotNull(result);
        }