Ejemplo n.º 1
0
        public async Task DeleteNullMediatorResponseAsync()
        {
            // Act
            var quoteId = new Guid("6877d1a3-4bc7-4d0b-b802-08d844d525ac");

            mediatR.Setup(m => m.Send(It.IsAny <GetQuoteByIdRequest>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult <Quote>(null));
            controller = new QuoteController(mapper, mediatR.Object);
            var result = await controller.Delete(quoteId) as BadRequestObjectResult;

            // Assert
            Assert.NotNull(result);
            Assert.AreEqual(400, result.StatusCode);
            Assert.AreEqual("No quote found with the id 6877d1a3-4bc7-4d0b-b802-08d844d525ac", result.Value);
        }
Ejemplo n.º 2
0
        public async Task DeleteThrowsExceptionAsync()
        {
            // Act
            var quoteId = new Guid("6877d1a3-4bc7-4d0b-b802-08d844d525ac");

            mediatR.Setup(m => m.Send(It.IsAny <GetQuoteByIdRequest>(), It.IsAny <CancellationToken>())).Throws(new InvalidOperationException());
            controller = new QuoteController(mapper, mediatR.Object);
            var result = await controller.Delete(quoteId) as ObjectResult;

            // Assert
            Assert.NotNull(result);
            Assert.AreEqual(400, result.StatusCode);
            Assert.AreEqual("Operation is not valid due to the current state of the object.", result.Value);
        }
Ejemplo n.º 3
0
        public async Task DeleteAsync()
        {
            // Act
            var quoteId = new Guid("6877D1A3-4BC7-4D0B-B802-08D844D525AC");
            var result  = await controller.Delete(quoteId) as OkObjectResult;

            // Assert
            Assert.NotNull(result);
            Assert.AreEqual(200, result.StatusCode);
            var responseQuoteModel = result.Value as ResponseQuoteModel;

            Assert.NotNull(responseQuoteModel);
            Assert.AreEqual("ClientName 1", responseQuoteModel.ClientName);
        }