Esempio n. 1
0
        public async Task returns_list_of_paystations()
        {
            // Arrange
            var mockRepo = new Mock <IPayStationRepo>();

            mockRepo.Setup(repo => repo.Retrieve())
            .Returns(Task.FromResult(GetPayStations()));

            var controller = new PayStationController(mockRepo.Object);

            // Act
            var actionResult = await controller.GetAllPaymentStations();

            Assert.IsNotNull(actionResult);

            // Assert
            var okResult = actionResult as OkObjectResult;

            Assert.IsNotNull(okResult);
            Assert.IsTrue(okResult.StatusCode.Equals(200));

            List <PaymentStationRecord> messages = okResult.Value as List <PaymentStationRecord>;

            Assert.IsTrue(messages.Count == 2);

            Assert.IsTrue(messages[0].PayStationName.Equals("Fred Meyer"));
            Assert.IsTrue(messages[1].PayStationName.Equals("Safeway #1"));

            //fluent assertions
            messages.Count.Should().Be(2);
            var okRes   = actionResult.Should().BeOfType <OkObjectResult>().Subject;
            var station = okResult.Value.Should().BeAssignableTo <List <PaymentStationRecord> >().Subject;

            mockRepo.Verify();
        }
Esempio n. 2
0
        public async Task returns_paystation_by_id()
        {
            // Arrange
            var mockRepo = new Mock <IPayStationRepo>();

            mockRepo.Setup(repo => repo.Retrieve())
            .Returns(Task.FromResult(GetPayStations()));

            var controller = new PayStationController(mockRepo.Object);

            // Act
            var actionResult = await controller.GetPaymentStationById("0000069");

            Assert.NotNull(actionResult);

            // Assert
            var okResult = actionResult as OkObjectResult;

            Assert.NotNull(okResult);
            Assert.Equal(200, okResult.StatusCode);

            List <PaymentStationRecord> messages = okResult.Value as List <PaymentStationRecord>;

            Assert.Single(messages);

            ////fluent assertions
            messages.Count.Should().Be(1);
            var okRes   = actionResult.Should().BeOfType <OkObjectResult>().Subject;
            var station = okResult.Value.Should().BeAssignableTo <List <PaymentStationRecord> >().Subject;


            mockRepo.Verify();
        }
Esempio n. 3
0
        public async Task returns_list_of_paystations()
        {
            // Arrange
            var mockRepo = Substitute.For <IPayStationRepo>();

            mockRepo.Retrieve().Returns(Task.FromResult(GetPayStations()));

            var controller = new PayStationController(mockRepo);

            // Act
            var actionResult = await controller.GetAllPaymentStations();

            Assert.NotNull(actionResult);

            // Assert
            var okResult = actionResult as OkObjectResult;

            Assert.NotNull(okResult);
            Assert.Equal(200, okResult.StatusCode);

            List <PaymentStationRecord> messages = okResult.Value as List <PaymentStationRecord>;

            Assert.Equal(2, messages.Count);
            Assert.Equal("Fred Meyer", messages[0].PayStationName);
            Assert.Equal("Safeway #1", messages[1].PayStationName);


            //fluent assertions
            messages.Count.Should().Be(2);
            var okRes   = actionResult.Should().BeOfType <OkObjectResult>().Subject;
            var station = okResult.Value.Should().BeAssignableTo <List <PaymentStationRecord> >().Subject;
        }
Esempio n. 4
0
        public async Task returns_no_content_result()
        {
            // Arrange
            var mockRepo = Substitute.For <IPayStationRepo>();

            mockRepo.Retrieve().Returns(Task.FromResult(EmptyPayStations()));

            var controller = new PayStationController(mockRepo);

            // Act
            var actionResult = await controller.GetAllPaymentStations();

            //fluent assertion
            var okRes = actionResult.Should().BeOfType <NoContentResult>().Subject;
        }