コード例 #1
0
        public async void Get_all_errors_fail()
        {
            //Arrange
            _logErrorServiceMock.Setup(x => x.Get(null))
            .Returns(Task.FromResult(new Response <List <ListLogErrorsViewModel> >(success: false, errors: null)));

            //Act

            var logErrorController = new LogErrorsController(_logErrorServiceMock.Object, _loggerMock.Object);
            var actionResult       = await logErrorController.GetAll();

            var result = actionResult.Result as NotFoundObjectResult;

            // Assert
            result.StatusCode.Should()
            .Be((int)HttpStatusCode.NotFound);
        }
コード例 #2
0
        public async void Get_all_errors_by_environment()
        {
            //Arrange
            List <ListLogErrorsViewModel> listLogErrorsViewModel = new List <ListLogErrorsViewModel>();

            listLogErrorsViewModel.Add(CreateListLogErrorsViewModel(5, "Our Log Error", EEnvironment.Production, ELevel.Warning, "Source", "Details", 300, false, 1));
            listLogErrorsViewModel.Add(CreateListLogErrorsViewModel(1, "Log Error", EEnvironment.Production, ELevel.Warning, "Source", "Details", 300, false, 2));
            listLogErrorsViewModel.Add(CreateListLogErrorsViewModel(1, "Log Error", EEnvironment.Development, ELevel.Warning, "Source", "Details", 300, false, 3));

            List <ListLogErrorsViewModel> expected = new List <ListLogErrorsViewModel>();

            listLogErrorsViewModel.Add(listLogErrorsViewModel[0]);
            listLogErrorsViewModel.Add(listLogErrorsViewModel[1]);

            GetLogErrorsQueryViewModel query = new GetLogErrorsQueryViewModel {
                Environment = EEnvironment.Production
            };

            Response <List <ListLogErrorsViewModel> > response = new Response <List <ListLogErrorsViewModel> >(data: expected, success: true, errors: null);

            _logErrorServiceMock.Setup(x => x.Get(query))
            .Returns(Task.FromResult(response));

            // Act
            var logErrorController = new LogErrorsController(_logErrorServiceMock.Object, _loggerMock.Object);
            var actionResult       = await logErrorController.GetAll(query);

            var result = actionResult.Result as OkObjectResult;


            // Assert
            result.StatusCode.Should()
            .Be((int)HttpStatusCode.OK);

            var obtainedResponse = result.Value as Response <List <ListLogErrorsViewModel> >;

            obtainedResponse.Should()
            .BeEquivalentTo(response);
        }
コード例 #3
0
        public async void Get_all_log_errors(int userId, string title, EEnvironment environment, ELevel level, string source, string details, int events, bool filed, int id)
        {
            //Arrange
            List <ListLogErrorsViewModel> listLogErrorsViewModel = new List <ListLogErrorsViewModel>();

            listLogErrorsViewModel.Add(
                new ListLogErrorsViewModel(
                    userId: userId,
                    filed: filed,
                    title: title,
                    environment: environment,
                    level: level,
                    source: source,
                    details: details,
                    events: events,
                    id: id
                    ));

            Response <List <ListLogErrorsViewModel> > response = new Response <List <ListLogErrorsViewModel> >(data: listLogErrorsViewModel, success: true, errors: null);

            _logErrorServiceMock.Setup(x => x.Get(null))
            .Returns(Task.FromResult(response));

            //Act
            var logErrorController = new LogErrorsController(_logErrorServiceMock.Object, _loggerMock.Object);
            var actionResult       = await logErrorController.GetAll();

            var result = actionResult.Result as OkObjectResult;


            // Assert
            result.StatusCode.Should()
            .Be((int)HttpStatusCode.OK);

            var obtainedResponse = result.Value as Response <List <ListLogErrorsViewModel> >;

            obtainedResponse.Should()
            .BeEquivalentTo(response);
        }