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

            // 1: Call GET Action
            var query = await establishmentsController.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("$", "Estabelecimento"), (string)resultType.GetProperty("Message").GetValue(result));
        }
예제 #2
0
        public async void Get_ThrowsException_Test()
        {
            // 1: Mocking GetAll Method to throws
            var establishmentServiceMock = new Mock <EstablishmentService>(dbSettings);

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

            var establishmentsControllerLocal = new EstablishmentsController(loggerWrapper, establishmentServiceMock.Object, controllerMessages);

            // 2: Call GET Action and Expects to throws
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await establishmentsControllerLocal.Get());
        }