コード例 #1
0
        public void GetSystemBuildStatistics_HappyPathTest()
        {
            var tgimbaApi   = new SharedTgimbaApiController(this.tgimbaService.Object, this.validationHelper.Object);
            var createdDate = DateTime.UtcNow.ToString();
            var systemBuildStatisticsToReturn = new List <SystemBuildStatistic>();

            systemBuildStatisticsToReturn.Add(new SystemBuildStatistic()
            {
                Start       = createdDate,
                End         = createdDate,
                BuildNumber = "I am a build number",
                Status      = "I am a status",
            });

            tgimbaService.Setup(x => x.GetSystemBuildStatistics(It.IsAny <string>(),
                                                                It.IsAny <string>()))
            .Returns(systemBuildStatisticsToReturn);

            IActionResult  result        = tgimbaApi.GetSystemBuildStatistics("encodedUser", "encodedToken");
            OkObjectResult requestResult = (OkObjectResult)result;

            Assert.IsNotNull(requestResult);
            Assert.AreEqual(200, requestResult.StatusCode);
            tgimbaService.Verify(x => x.GetSystemBuildStatistics("encodedUser", "encodedToken"), Times.Once);
            var systemStatistics = (List <SystemBuildStatistic>)requestResult.Value;

            Assert.AreEqual(1, systemStatistics.Count);
            Assert.AreEqual(systemBuildStatisticsToReturn, systemStatistics);
        }
コード例 #2
0
        public void GetSystemBuildStatistics_GeneralErrorTest()
        {
            var tgimbaApi = new SharedTgimbaApiController(this.tgimbaService.Object, this.validationHelper.Object);
            var exception = "I am an exception";

            tgimbaService.Setup(x => x.GetSystemBuildStatistics(It.IsAny <string>(),
                                                                It.IsAny <string>()))
            .Throws(new Exception(exception));
            IActionResult    result        = tgimbaApi.GetSystemBuildStatistics("encodedUser", "encodedToken");
            StatusCodeResult requestResult = (StatusCodeResult)result;

            tgimbaService.Verify(x => x.Log(It.Is <string>(s => s == exception)), Times.Once);
            Assert.IsNotNull(requestResult);
            Assert.AreEqual(500, requestResult.StatusCode);
        }
コード例 #3
0
        public void GetSystemBuildStatistics_NoResultEmptyCollection()
        {
            var tgimbaService    = new Mock <ITgimbaService>();
            var validationHelper = new Mock <IValidationHelper>();
            var tgimbaApi        = new SharedTgimbaApiController(this.tgimbaService.Object, this.validationHelper.Object);
            var systemBuildStatisticsToReturn = new List <SystemBuildStatistic>();

            tgimbaService.Setup(x => x.GetSystemBuildStatistics(It.IsAny <string>(),
                                                                It.IsAny <string>()))
            .Returns(systemBuildStatisticsToReturn);

            IActionResult    result        = tgimbaApi.GetSystemBuildStatistics("encodedUser", "encodedToken");
            StatusCodeResult requestResult = (StatusCodeResult)result;

            Assert.IsNotNull(requestResult);
            Assert.AreEqual(404, requestResult.StatusCode);
        }