public async Task UserLeft_UserNull() { //assemble var queryContext = AssembleMocks.GetQueryContext(); var commandContext = AssembleMocks.GetCommandContext(); var userSummaryRepo = new UserSummaryRepository(queryContext.Object); var conversationRepo = new ConversationRepository(queryContext.Object, commandContext.Object); var messageRepo = new MessageRepository(queryContext.Object, commandContext.Object); var conversationContext = new ConversationBoundedContext(conversationRepo, userSummaryRepo, messageRepo); var conversation = await conversationContext.GetById(4); var userSummary = await userSummaryRepo.GetById(1); var userSummaryTest = await userSummaryRepo.GetById(5); conversation.UserJoined(userSummary); //workaround since can't seem to mock a working Include() Assert.IsTrue(conversation.ActiveUsers.Count() == 1); //act conversation.UserLeft(userSummaryTest); //assert Assert.IsNull(userSummaryTest); Assert.IsTrue(conversation.ActiveUsers.Count() == 1); }
public async Task Create_NotNullTopic() { //assemble var queryContext = AssembleMocks.GetQueryContext(); var commandContext = AssembleMocks.GetCommandContext(); var conversationRepo = new ConversationRepository(queryContext.Object, commandContext.Object); //act var conversation = await conversationRepo.Create("New Topic"); //assert Assert.IsNotNull(conversation); }
public async Task GetBySignalRConnectionIdWithActiveUser_NotFound() { //assemble var queryContext = AssembleMocks.GetQueryContext(true); var commandContext = AssembleMocks.GetCommandContext(true); var conversationRepo = new ConversationRepository(queryContext.Object, commandContext.Object); //act var conversationId = await conversationRepo.GetConversationIdBySignalRId("bc0444a5-c967-4d9f-86eb-0d9359d1bda3"); //assert Assert.IsTrue(conversationId == 0); }
public async Task GetById_NotFound() { //assemble var queryContext = AssembleMocks.GetQueryContext(); var commandContext = AssembleMocks.GetCommandContext(); var conversationRepo = new ConversationRepository(queryContext.Object, commandContext.Object); //act var conversation = await conversationRepo.GetById(15, null); //assert Assert.IsNull(conversation); }
public async Task GetAllActive() { //assemble var queryContext = AssembleMocks.GetQueryContext(); var commandContext = AssembleMocks.GetCommandContext(); var conversationRepo = AssembleMocks.GetConversationRepo(queryContext, commandContext); //act var conversations = await conversationRepo.Object.GetAllActive(); //assert Assert.IsNotNull(conversations); Assert.IsTrue(conversations.Count() == 3); }
public async Task Persist() { //assemble var queryContext = AssembleMocks.GetQueryContext(); var commandContext = AssembleMocks.GetCommandContext(); var conversationRepo = new ConversationRepository(queryContext.Object, commandContext.Object); var conversation = await conversationRepo.GetById(1, null); string newTopic = Guid.NewGuid().ToString(); //act conversation.Topic = newTopic; var response = await conversationRepo.Persist(conversation); //assert Assert.IsTrue(response.Topic == newTopic); }
public async Task UserJoined_UserNull() { //assemble var queryContext = AssembleMocks.GetQueryContext(); var commandContext = AssembleMocks.GetCommandContext(); var userSummaryRepo = new UserSummaryRepository(queryContext.Object); var conversationRepo = new ConversationRepository(queryContext.Object, commandContext.Object); var messageRepo = new MessageRepository(queryContext.Object, commandContext.Object); var conversationContext = new ConversationBoundedContext(conversationRepo, userSummaryRepo, messageRepo); var conversation = await conversationContext.GetById(5); var userSummary = await userSummaryRepo.GetById(5); //act conversation.UserJoined(userSummary); //assert Assert.IsNull(userSummary); Assert.IsTrue(conversation.ActiveUsers.Count() == 0); }