public async Task Should_Cancel_Registration() { //Arrange var currentUserId = AbpSession.GetUserId(); await UsingDbContext(async context => { var testEvent = GetTestEvent(context); var currentUser = await context.Users.SingleAsync(u => u.Id == currentUserId); var testRegistration = await EventRegistration.CreateAsync( testEvent, currentUser, Substitute.For <IEventRegistrationPolicy>() ); context.EventRegistrations.Add(testRegistration); }); //Act await _eventAppService.CancelRegistration(new EntityDto <Guid>(GetTestEvent().Id)); //Assert UsingDbContext(context => { var testEvent = GetTestEvent(context); var testRegistration = context.EventRegistrations.FirstOrDefault(r => r.EventId == testEvent.Id && r.UserId == currentUserId); testRegistration.ShouldBeNull(); }); }