예제 #1
0
        public async void Get_StatusCode_404_Test()
        {
            // 0: Remove all releases from database
            await releasesService.RemoveAll();

            // 1: Call GET Action
            var query = await releasesController.Get();

            var  result     = query.Result.GetType().GetProperty("Value").GetValue(query.Result);
            Type resultType = result.GetType();

            Assert.Equal(404, (int)resultType.GetProperty("StatusCode").GetValue(result));
            Assert.Equal(controllerMessages.NotFound.Replace("$", "Lançamento"), (string)resultType.GetProperty("Message").GetValue(result));
        }
예제 #2
0
        public async void Get_ThrowsException_Test()
        {
            // 1: Mocking GetAll Method to throws
            var releasesServiceMock = new Mock <ReleasesService>(dbSettings);

            releasesServiceMock.Setup(es => es.GetAll()).ThrowsAsync(new InvalidOperationException());

            var releasesControllerLocal = new ReleasesController(loggerWrapper, releasesServiceMock.Object, establishmentService, controllerMessages);

            // 2: Call GET Action and Expects to throws
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await releasesControllerLocal.Get());
        }
예제 #3
0
        public void Get_ErrorOccursRetrievingReleaseData_InternalServerErrorReturned()
        {
            //Arrange
            var request = new GetReleasesHttpRequestMessageBuilder().Build();

            _releaseRepositoryMock.Setup((stub) => stub.GetReleaseData(It.IsAny <string>(), It.IsAny <int>()))
            .Throws <Exception>();

            //Act
            var result = _sut.Get(request);

            //Assert
            AssertionHelper.AssertHttpResponseMessageStatus(result, HttpStatusCode.InternalServerError);
        }