public void GivenCreatingGrade_WhenPosting_ThenCorrespondingGradeIsCreated() { // Arrange var testStudent = new Student("OliCreationTest", "test") { Id = 1, Grades = new List <Grade> { new Grade { Subject = "Maths" } } }; var testGrade = new Grade { Subject = "ICT", Score = 100 }; CreateStudentGradeMessage request = null; CreateStudentGradeReplyMessage reply = null; var queryCountWrapper = new Mock <IQueryCountWrapper>(); queryCountWrapper.SetupGet(qcw => qcw.QueryCount).Returns(0); var bus = new Mock <IBus>(MockBehavior.Strict); bus .Setup(b => b.SendRequest <CreateStudentGradeMessage, CreateStudentGradeReplyMessage> (It.IsAny <string>(), It.IsAny <CreateStudentGradeMessage>(), null, It.IsAny <int>())) .Returns <string, CreateStudentGradeMessage, Dictionary <string, string>, int>( (endpoint, message, headers, timeout) => { request = message; reply = new CreateStudentGradeReplyMessage(message.CorrelationId); return(reply); }); var claimsHelper = new Mock <IClaimsHelper>(MockBehavior.Strict); var controller = new StudentController(bus.Object, claimsHelper.Object, queryCountWrapper.Object); // Act var result = controller.CreateGrade(testGrade, 1); var okObjectResult = result as AcceptedResult; // Assert Assert.NotNull(okObjectResult); }