public async Task ShouldGetAll()
        {
            var mock = new Mock <IFundManagerRepository>();
            var controller = new FundManagerController(mock.Object);
            var valueFunction = new[] { new FundManager() }.AsQueryable();

            mock.Setup(m => m.GetAll()).Returns(Task.FromResult(valueFunction));

            var result = await controller.Get();

            Assert.That(result.Count(), Is.EqualTo(1));
        }
        public async Task ShouldGet()
        {
            var mock        = new Mock <IFundManagerRepository>();
            var controller  = new FundManagerController(mock.Object);
            var newGuid     = Guid.NewGuid();
            var fundManager = new FundManager();

            mock.Setup(m => m.GetBy(newGuid)).Returns(Task.FromResult(fundManager));

            var result = controller.Get(newGuid);

            mock.Verify();
            Assert.That(await result, Is.EqualTo(fundManager));
        }
Exemple #3
0
        public async Task ShouldGetAll()
        {
            //Arrange
            var mock       = new Mock <IFundManagerRepository>();
            var controller = new FundManagerController(mock.Object);
            IEnumerable <FundManager> valueFunction = new[] { new FundManager() };

            mock.Setup(m => m.GetAll())
            .Returns(Task.FromResult(valueFunction))
            .Verifiable();

            //Act
            var result = await controller.Get();

            //Assert
            Assert.That(result.Count(), Is.EqualTo(1));
        }