Exemple #1
0
        public async Task Run_ReturnsNoContentOnSuccess()
        {
            var handler   = new Mock <ICommandHander <DeleteListCommand> >();
            var container = new Container();
            var id        = Guid.NewGuid().ToString();
            var request   = new DefaultHttpRequest(new DefaultHttpContext());

            handler.Setup(h => h.Execute(It.IsAny <DeleteListCommand>())).Returns(Task.CompletedTask);
            container.RegisterInstance(handler.Object);
            container.RegisterInstance(_telemetryClient);
            DeleteList.Container = container;

            var result = await DeleteList.Run(request, id) as NoContentResult;

            Assert.IsNotNull(result);
        }
Exemple #2
0
        public async Task Run_ReturnsServerErrorOnServerError()
        {
            var handler   = new Mock <ICommandHander <DeleteListCommand> >();
            var container = new Container();
            var id        = Guid.NewGuid().ToString();
            var request   = new DefaultHttpRequest(new DefaultHttpContext());

            handler.Setup(h => h.Execute(It.IsAny <DeleteListCommand>()))
            .ThrowsAsync(new Exception());
            container.RegisterInstance(handler.Object);
            container.RegisterInstance(_telemetryClient);
            DeleteList.Container = container;

            var result = await DeleteList.Run(request, id) as InternalServerErrorResult;

            Assert.IsNotNull(result);
        }