This forum is not used anymore. Please ask new questions to Stack Overflow: https://stackoverflow.com/questions/tag ... ort=newest (use aspnetboilerplate tag).
By drsmallbone
#5941 Hello!

First of all love your work!

I have just decided to create a new project with the latest templates (Amazing notifications/signalr stuff) and for the first time I decided to go TDD. I have not done much testing before and my async mental strength is lacking. However I spotted this and I am not sure it is a bug or I am not understanding the logic.

Code: Select all        [Fact]
        public async Task CreateUser_Test()
        {
            //Act
            await _userAppService.CreateUser(
                new CreateUserInput
                {
                    EmailAddress = "john@volosoft.com",
                    IsActive = true,
                    Name = "John",
                    Surname = "Nash",
                    Password = "123qwe",
                    UserName = "john.nash"
                });

            await UsingDbContextAsync(async context =>
            {
                var johnNashUser = await context.Users.FirstOrDefaultAsync(u => u.UserName == "john.naash");
                johnNashUser.ShouldNotBeNull();
            });
        }

        [Fact]
        public async Task CreateUser_Without_Async_Context_Test()
        {
            //Act
            await _userAppService.CreateUser(
                new CreateUserInput
                {
                    EmailAddress = "john@volosoft.com",
                    IsActive = true,
                    Name = "John",
                    Surname = "Nash",
                    Password = "123qwe",
                    UserName = "john.nash"
                });

            await UsingDbContext(async context =>
            {
                var johnNashUser = await context.Users.FirstOrDefaultAsync(u => u.UserName == "john.naash");
                johnNashUser.ShouldNotBeNull();
            });
        }


I have set it so they will both fail as the username should not match however the default test with UsingDbContextAsync will return a NULL but will not fail the test.

:? :?

If I correct the Username they will both pass.

Thanks