public void TestSQLDataBaseBoardCRUD() { SQLDataBaseBoardChatMessage sQLDataBaseBoardChatMessage = new SQLDataBaseBoardChatMessage(new SQLDBConfigurationProvider(), new ChatMessageEnvelopeFactory()); IChatMessageEnvelope chatMessageEnvelope = _erector.Container.Resolve <IChatMessageEnvelope>(); chatMessageEnvelope.ChatChannelName = "love"; chatMessageEnvelope.ChatChannelID = 1; chatMessageEnvelope.ChatMessageBody = "Jesus Loves You."; //Create IChatMessageEnvelope newChatMessageEnvelope = (IChatMessageEnvelope)sQLDataBaseBoardChatMessage.POST(chatMessageEnvelope); Assert.IsNotNull(newChatMessageEnvelope); Assert.IsNotNull(newChatMessageEnvelope.CreatedDateTime); newChatMessageEnvelope.Query = (queryRepo, envelope) => { return(queryRepo.GetChatMessageByID(envelope)); }; //Read IChatMessageEnvelope readChatMessageEnvelope = (IChatMessageEnvelope)sQLDataBaseBoardChatMessage.GET(newChatMessageEnvelope); Assert.IsNotNull(readChatMessageEnvelope); Assert.AreEqual(readChatMessageEnvelope.ChatMessageID, newChatMessageEnvelope.ChatMessageID); //Update IChatMessageEnvelope updateChatMessageEnvelope = (IChatMessageEnvelope)sQLDataBaseBoardChatMessage.PUT(readChatMessageEnvelope); Assert.IsNotNull(updateChatMessageEnvelope); Assert.IsTrue(DateTime.Compare(readChatMessageEnvelope.ModifiedDateTime, updateChatMessageEnvelope.ModifiedDateTime) < 0); //Delete IChatMessageEnvelope deletedChatMessageEnvelope = (IChatMessageEnvelope)sQLDataBaseBoardChatMessage.DELETE(updateChatMessageEnvelope); Assert.IsNotNull(updateChatMessageEnvelope); Assert.IsTrue(DateTime.Compare(updateChatMessageEnvelope.ModifiedDateTime, deletedChatMessageEnvelope.ModifiedDateTime) < 0); }
public void TestGetNextChatMessage() { SQLDataBaseBoardChatMessage sQLDataBaseBoardChatMessage = new SQLDataBaseBoardChatMessage(new SQLDBConfigurationProvider(), new ChatMessageEnvelopeFactory()); IChatMessageEnvelope sameChannelChatMessageEnvelope = _erector.Container.Resolve <IChatMessageEnvelope>(); sameChannelChatMessageEnvelope.ChatChannelName = "love"; sameChannelChatMessageEnvelope.ChatMessageBody = "Jesus Loves You."; sameChannelChatMessageEnvelope.ChatChannelID = 1; IChatMessageEnvelope newChatMessageEnvelope = (IChatMessageEnvelope)sQLDataBaseBoardChatMessage.POST(sameChannelChatMessageEnvelope); IChatMessageEnvelope chatMessageEnvelope = _erector.Container.Resolve <IChatMessageEnvelope>(); chatMessageEnvelope.ChatMessageID = 1; chatMessageEnvelope.Query = (queryRepo, envelope) => { return(queryRepo.GetChatMessageByID(envelope)); }; IChatMessageEnvelope readChatMessageEnvelope = (IChatMessageEnvelope)sQLDataBaseBoardChatMessage.GET(chatMessageEnvelope); IChatMessageEnvelope nextChatMessageEnvelope = sQLDataBaseBoardChatMessage.GetNextChatMessage(readChatMessageEnvelope); Assert.IsNotNull(nextChatMessageEnvelope); Assert.IsTrue(nextChatMessageEnvelope.ChatMessageID > readChatMessageEnvelope.ChatMessageID); }