public void SourceAndDestinationAreNotSame() { #region Setup for test testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object); repoInstance.Setup(ent => ent.Add(It.IsAny<MessagePing>())).Returns(dummyMessage); MessagePing testData = new MessagePing() { Source = "+919840200524", Destination = "+919840200524", Message = "Hello!", MessageSentUTC = DateTime.UtcNow }; #endregion #region Test and Assert bool postResult = testSubject.PostMessage(testData); Assert.IsFalse(postResult); #endregion }
public void SentTimeIsLessThanMaxTime() { testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object); MessagePing data = new MessagePing() { Id = Guid.NewGuid(), Source = DefaultSource, Destination = DefaultDestination, Message = "Hi!!", MessageSentUTC = DateTime.MaxValue, MessageRecievedUTC = null }; bool returnValue = testSubject.PostMessage(data); Assert.IsFalse(returnValue); }
public void PostMessageSucceeds() { #region Setup for test testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object); bool returnValue; repoInstance.Setup(ent => ent.Add(It.IsAny<MessagePing>())).Returns(dummyMessage); #endregion #region Test returnValue = testSubject.PostMessage(dummyMessage); repoInstance.Verify(ent => ent.Add(dummyMessage),Times.AtLeastOnce,"Was called lesser than once"); Assert.IsTrue(returnValue); #endregion }
public void RecievedTimeIsAlwaysGreaterThanSentTime() { testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object); DateTime timestamp = DateTime.UtcNow; MessagePing data = new MessagePing() { Id = Guid.NewGuid(), Source = DefaultSource, Destination = DefaultDestination, Message = "Hi!!", MessageSentUTC = timestamp.AddMilliseconds(1), MessageRecievedUTC = timestamp }; bool returnValue = testSubject.PostMessage(data); Assert.IsFalse(returnValue); }
public void SentTimeIsExactly1WeekInPast() { testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object); MessagePing data = new MessagePing() { Id = Guid.NewGuid(), Source = DefaultSource, Destination = DefaultDestination, Message = "Hi!!", MessageSentUTC = DateTime.UtcNow.AddDays(Exactly1WeekPast), MessageRecievedUTC = null }; bool returnValue = testSubject.PostMessage(data); Assert.IsTrue(returnValue); }
public void IsRecievedTimeWithinPast1Hour() { testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object); MessagePing data = new MessagePing() { Id = Guid.NewGuid(), Source = DefaultSource, Destination = DefaultDestination, Message = "Hi!!", MessageSentUTC = DateTime.UtcNow, MessageRecievedUTC = null }; bool returnValue = testSubject.PostMessage(data); Assert.IsTrue(DateTime.UtcNow.AddHours(Within1HourPast) < passedToRepo.MessageRecievedUTC); }
public void IsTimeRecievedInUTCForMessage() { testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object); DateTime timestamp = DateTime.Now; MessagePing data = new MessagePing() { Id = Guid.NewGuid(), Source = DefaultSource, Destination = DefaultDestination, Message = "Hi!!", MessageSentUTC = timestamp, MessageRecievedUTC = null }; bool returnValue = testSubject.PostMessage(data); Assert.IsTrue(DateTimeKind.Utc == data.MessageRecievedUTC.Value.Kind); }
public void IsRecievedTimeBetweenMinAndMaxDateTimeValue() { testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object); MessagePing data = new MessagePing() { Id = Guid.NewGuid(), Source = DefaultSource, Destination = DefaultDestination, Message = "Hi!!", MessageSentUTC = DateTime.UtcNow, MessageRecievedUTC = null }; bool returnValue = testSubject.PostMessage(data); Assert.IsTrue(DateTime.MinValue < passedToRepo.MessageRecievedUTC && DateTime.MaxValue > passedToRepo.MessageRecievedUTC); }
public void DoesServerPreserveSentTimeForMessage() { testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object); DateTime timestamp = DateTime.UtcNow; MessagePing data = new MessagePing() { Id = Guid.NewGuid(), Source = DefaultSource, Destination = DefaultDestination, Message = "Hi!!", MessageSentUTC = timestamp, MessageRecievedUTC = null }; bool returnValue = testSubject.PostMessage(data); Assert.AreEqual(data.MessageSentUTC, timestamp); }
public void DoesServerAddRecievedTimeForMessage() { testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object); MessagePing data = new MessagePing() { Id = Guid.NewGuid(), Source = DefaultSource, Destination = DefaultDestination, Message = "Hi!!", MessageSentUTC = DateTime.UtcNow, MessageRecievedUTC = null }; bool returnValue = testSubject.PostMessage(data); Assert.IsNotNull(passedToRepo.MessageRecievedUTC); }
public void DoesMessageHaveMessageSentTime() { //TODO: Properly instantiate the WorkerProcess testSubject = new WorkerProcess(repoInstance.Object, null, null); MessagePing data = new MessagePing() { Id = Guid.NewGuid(), Source = DefaultSource, Destination = DefaultDestination, Message = "Hi!!", MessageSentUTC = DateTime.MinValue, MessageRecievedUTC = null }; bool returnValue = testSubject.PostMessage(data); Assert.IsFalse(returnValue); }
public void BothSentAndRecievedTimeAreNotPresent() { testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object); MessagePing data = new MessagePing() { Id = Guid.NewGuid(), Source = DefaultSource, Destination = DefaultDestination, Message = "Hi!!", MessageSentUTC = null, MessageRecievedUTC = null }; bool returnValue = testSubject.PostMessage(data); Assert.IsFalse(returnValue); }