Ejemplo n.º 1
0
        public async void GetAllOwnersNoAutoMapper_Sorts_Results_By_Name()
        {
            // Arrange
            var mockOwnerRepository   = new Mock <IOwnerRepository>();
            var mockRepositoryWrapper = new Mock <IRepositoryWrapper>();


            var dylan = new Owner()
            {
                Id       = Guid.NewGuid(),
                Name     = "Dylan",
                Address  = "my address",
                Accounts = new List <Account>()
            };

            var crystal = new Owner()
            {
                Id       = Guid.NewGuid(),
                Name     = "Crystal",
                Address  = "my address",
                Accounts = new List <Account>()
            };

            var ownersToReturn = new List <Owner>()
            {
                dylan,
                crystal
            }.AsQueryable();

            mockOwnerRepository.Setup(m => m.FindAll()).Returns(ownersToReturn);

            var mockLogger = NullLogger <OwnerService> .Instance;

            var mockMapper = new Mock <IMapper>();

            // Act
            var ownerService = new OwnerService(mockRepositoryWrapper.Object, mockLogger, mockMapper.Object);
            var result0      = await ownerService.GetAllOwnersNoAutoMapperAsync();

            var result = result0.ToList();

            // Assert
            Assert.Equal(2, result.Count());
            Assert.True("Crystal" == result[0].Name);
            Assert.True("Dylan" == result[1].Name);
        }