Ejemplo n.º 1
0
        public void Test_CIndex_ReturnsCIndexView()
        {
            var expected = "Index";

            CharitiesController classUnderTest = new CharitiesController();

            var actual = classUnderTest.Index() as ViewResult;

            Assert.AreEqual(expected, actual.ViewName);
        }
        public async Task GetCharity_ReturnsAppropriateResponse(int registrationNumber, int expectedStatusCode)
        {
            var mediatorMock = new Mock <IMediator>();

            mediatorMock.Setup(m => m.Send(It.Is <GetCharityQuery>(q => q.RegistrationNumber == InvalidRegistrationNumber), It.IsAny <CancellationToken>())).ReturnsAsync(new GetCharityResult(null));
            mediatorMock.Setup(m => m.Send(It.Is <GetCharityQuery>(q => q.RegistrationNumber == ValidRegistrationNumber), It.IsAny <CancellationToken>())).ReturnsAsync(new GetCharityResult(new Charity()));

            var subject = new CharitiesController(mediatorMock.Object, Mock.Of <ILogger <CharitiesController> >());

            var response = await subject.GetCharity(registrationNumber);

            var statusCodeResult = response as IStatusCodeActionResult;

            Assert.AreEqual(expectedStatusCode, statusCodeResult.StatusCode.GetValueOrDefault());
        }