public CreateSampleEntities ( dynamic message ) : void | ||
message | dynamic | The dynamic message from the bus containing the details of the item to be updated |
return | void |
public void PostOperationWith2SolutionsLogsSuccessfullStoreOfEntitieTwice() { var publisher = new Mock<IMessagePublisher>(); var logger = new Mock<ILogger>(); var repo = new FakeRepository(); var env = new Mock<IEnvironment>(); var logicClass = new DataOperations(logger.Object, publisher.Object, repo, env.Object); var invocations = new List<string>(); logger.Setup(l => l.Info(It.IsAny<string>(), It.IsAny<object>())) .Callback<string, object[]>((message, obj) => invocations.Add(message)); logicClass.CreateSampleEntities(TestMessages.GetTestCreateSampleEntityMessageWithMultiple()); Assert.IsTrue(invocations[1].Contains("Created entity")); Assert.IsTrue(invocations[2].Contains("Created entity")); Assert.IsTrue(invocations.Count == 3); }
public void PostOperationRaisesNewEvent() { var publisher = new Mock<IMessagePublisher>(); var logger = new Mock<ILogger>(); var repo = new FakeRepository(); var env = new Mock<IEnvironment>(); var logicClass = new DataOperations(logger.Object, publisher.Object, repo, env.Object); var loggerInvocations = new List<string>(); var messageInvocations = new List<dynamic>(); logger.Setup(l => l.Info(It.IsAny<string>(), It.IsAny<object>())) .Callback<string, object[]>((message, obj) => loggerInvocations.Add(message)); publisher.Setup(p => p.Publish(It.IsAny<object>(), It.IsAny<string>())).Callback<object, string>((msg, str) => messageInvocations.Add(msg)); logicClass.CreateSampleEntities(TestMessages.GetTestCreateSampleEntityMessageWithMultiple()); Assert.IsTrue(messageInvocations.Count > 0); }
public void PostOperationLogsErrorIfUnableToStore() { var publisher = new Mock<IMessagePublisher>(); var logger = new Mock<ILogger>(); var repo = new Mock<IRepository<SampleEntity>>(); var env = new Mock<IEnvironment>(); var logicClass = new DataOperations(logger.Object, publisher.Object, repo.Object, env.Object); var invocations = new List<string>(); logger.Setup(l => l.Error(It.IsAny<Exception>(), It.IsAny<string>(), It.IsAny<object[]>())) .Callback<Exception, string, object[]>((ex, message, obj) => invocations.Add(message)); repo.Setup(r => r.Add(It.IsAny<IEnumerable<SampleEntity>>())).Throws(new Exception("Test exception")); logicClass.CreateSampleEntities(TestMessages.GetTestCreateSampleEntityMessageWithMultiple()); Assert.IsTrue(invocations[0].Contains("Unable to create entity")); }
public void PostOperationRaisesFailEventIfUnableToStore() { var publisher = new Mock<IMessagePublisher>(); var logger = new Mock<ILogger>(); var repo = new Mock<IRepository<SampleEntity>>(); var env = new Mock<IEnvironment>(); var logicClass = new DataOperations(logger.Object, publisher.Object, repo.Object, env.Object); var invocations = new List<string>(); var messageInvocations = new List<dynamic>(); logger.Setup(l => l.Error(It.IsAny<Exception>(), It.IsAny<string>(), It.IsAny<object[]>())) .Callback<Exception, string, object[]>((ex, message, obj) => invocations.Add(message)); repo.Setup(r => r.Add(It.IsAny<IEnumerable<SampleEntity>>())).Throws(new Exception("Test exception")); publisher.Setup(p => p.Publish(It.IsAny<object>(), It.IsAny<string>())).Callback<object, string>((msg, str) => messageInvocations.Add(msg)); logicClass.CreateSampleEntities(TestMessages.GetTestCreateSampleEntityMessageWithMultiple()); Assert.IsTrue(invocations[0].Contains("Test Error")); //what the hell should we check for)); }
public void PostOperationCreatesSingleDataEntity() { var publisher = new Mock<IMessagePublisher>(); var logger = new Mock<ILogger>(); var repo = new FakeRepository(); var env = new Mock<IEnvironment>(); var logicClass = new DataOperations(logger.Object, publisher.Object, repo, env.Object); logicClass.CreateSampleEntities(TestMessages.GetTestCreateSampleEntityMessage()); Assert.IsTrue(repo.Entities.Count.Equals(1)); }