Esempio n. 1
0
        public async System.Threading.Tasks.Task PutNoForm()
        {
            // Arrange
            this._betService     = new ProjectSpeedy.Tests.ServicesTests.Bet();
            this._problemService = new ProjectSpeedy.Tests.ServicesTests.ProblemData();
            this._controller     = new ProjectSpeedy.Controllers.BetController(this._logger.Object, this._betService, this._problemService);

            // Act
            ActionResult test = await this._controller.PutAsync("ProjectId", "ProblemId", null);

            // Assert
            // Taken from https://stackoverflow.com/questions/51489111/how-to-unit-test-with-actionresultt
            var result = test as BadRequestResult;

            Assert.AreEqual(400, result.StatusCode);
        }
Esempio n. 2
0
        public async System.Threading.Tasks.Task GetHttpException()
        {
            // Arrange
            this._betService = new ProjectSpeedy.Tests.ServicesTests.BetDataNotFoundOther();
            this._controller = new ProjectSpeedy.Controllers.BetController(this._logger.Object, this._betService, this._problemService);

            // Act
            var test = await this._controller.GetAsync("ProblemId", "ProjectId", "BetId");

            // Assert
            // Taken from https://stackoverflow.com/questions/51489111/how-to-unit-test-with-actionresultt
            var result = test.Result as ObjectResult;

            Assert.IsNull(test.Value);
            Assert.AreEqual(500, result.StatusCode);
        }
Esempio n. 3
0
        public async System.Threading.Tasks.Task PutException()
        {
            // Arrange
            this._betService     = new ProjectSpeedy.Tests.ServicesTests.BetDataNoCreate();
            this._problemService = new ProjectSpeedy.Tests.ServicesTests.ProblemDataException();
            this._controller     = new ProjectSpeedy.Controllers.BetController(this._logger.Object, this._betService, this._problemService);

            // Act
            ActionResult test = await this._controller.PutAsync("ProjectId", "ProblemId", new ProjectSpeedy.Models.Bet.BetNew()
            {
                Name = "New Bet Name"
            });

            // Assert
            // Taken from https://stackoverflow.com/questions/51489111/how-to-unit-test-with-actionresultt
            var result = test as ObjectResult;

            Assert.AreEqual(500, result.StatusCode);
        }