Ejemplo n.º 1
0
        public async Task Get_Ok()
        {
            var testDomains           = TestData.TestResultDomains;
            var testService           = DatabaseServiceGetMock.GetTestDatabaseTable(testDomains);
            var testTransferConverter = TestTransferConverterMock.TestTransferConverter;
            var testController        = new TestController(testService.Object, testTransferConverter);

            var actionResult = await testController.Get();

            var testsAfter = testTransferConverter.FromTransfers(actionResult.Value);

            Assert.True(testsAfter.Value.SequenceEqual(testDomains.Value));
        }
Ejemplo n.º 2
0
        public async Task GetById_Ok()
        {
            var testDomains           = TestData.TestResultDomains;
            var testGet               = testDomains.Value.Last();
            var testGetId             = testGet.Id;
            var testService           = DatabaseServiceGetMock.GetTestDatabaseTable(testDomains);
            var testTransferConverter = TestTransferConverterMock.TestTransferConverter;
            var testController        = new TestController(testService.Object, testTransferConverter);

            var actionResult = await testController.Get(testGetId);

            var testAfter = testTransferConverter.FromTransfer(actionResult.Value);

            Assert.True(testAfter.Value.Equals(testGet));
        }
Ejemplo n.º 3
0
        public async Task GetById_NotFound()
        {
            var testGetId             = TestData.TestDomains.Last().Id;
            var initialError          = ErrorData.DatabaseError;
            var testDomains           = new ResultCollection <ITestDomain>(initialError);
            var testService           = DatabaseServiceGetMock.GetTestDatabaseTable(testDomains, DatabaseServiceGetMock.GetByIdNotFoundFunc());
            var testTransferConverter = TestTransferConverterMock.TestTransferConverter;
            var testController        = new TestController(testService.Object, testTransferConverter);

            var actionResult = await testController.Get(testGetId);

            Assert.IsType <NotFoundResult>(actionResult.Result);
            var notFoundResult = (NotFoundResult)actionResult.Result;

            Assert.Equal(StatusCodes.Status404NotFound, notFoundResult.StatusCode);
        }
Ejemplo n.º 4
0
        public async Task Get_ErrorDatabase()
        {
            var initialError          = ErrorData.DatabaseError;
            var testDomains           = new ResultCollection <ITestDomain>(initialError);
            var testService           = DatabaseServiceGetMock.GetTestDatabaseTable(testDomains);
            var testTransferConverter = TestTransferConverterMock.TestTransferConverter;
            var testController        = new TestController(testService.Object, testTransferConverter);

            var actionResult = await testController.Get();

            Assert.IsType <BadRequestObjectResult>(actionResult.Result);
            var badRequest = (BadRequestObjectResult)actionResult.Result;
            var errors     = (SerializableError)badRequest.Value;

            Assert.Equal(StatusCodes.Status400BadRequest, badRequest.StatusCode);
            Assert.Equal(initialError.ErrorResultType.ToString(), errors.Keys.First());
        }