Ejemplo n.º 1
0
        public async Task GetStatisticsCollectionWithNonEmptyStatsList_ReturnsSerializedList()
        {
            // arrange
            var collectionRepositoryMock = new Mock<IRepository<DbCollection>>();
            var statisticsRepositoryMock = new Mock<IRepository<StatisticsEntity>>();
            var testDbCollection = new DbCollection
            {
                Id = "1",
                Description = "descr1",
                MembersCount = 1,
                Name = "name1",
                PrivacySettings = 0,
                ScreenName = "sname1",
                StatisticsList = new List<string>
                {
                    "aaa",
                    "bbb",
                    "ccc"
                }
            };
            collectionRepositoryMock.Setup(m => m.GetByIdAsync(It.IsAny<long>())).ReturnsAsync(testDbCollection);
            var controller = new HomeController(collectionRepositoryMock.Object, statisticsRepositoryMock.Object);

            // act
            var result = (await controller.GetStatisticCollections(1)).Data as List<string>;

            // assert
            Assert.That(result.Count, Is.EqualTo(testDbCollection.StatisticsList.Count));
            Assert.That(result[0], Is.EqualTo(testDbCollection.StatisticsList[0]));
        }
Ejemplo n.º 2
0
        public async Task GetStatisticsCollectionForEmptyStatisticsList_ReturnsNull()
        {
            // arrange
            var collectionRepositoryMock = new Mock<IRepository<DbCollection>>();
            var statisticsRepositoryMock = new Mock<IRepository<StatisticsEntity>>();

            collectionRepositoryMock.Setup(m => m.GetByIdAsync(It.IsAny<long>())).ReturnsAsync(new DbCollection()
            {
                Id = "1",
                Description = "descr1",
                MembersCount = 1,
                Name = "name1",
                PrivacySettings = 0,
                ScreenName = "sname1",
                StatisticsList = new List<string>()
            });
            var controller = new HomeController(collectionRepositoryMock.Object, statisticsRepositoryMock.Object);
            
            // act
            var result = await  controller.GetStatisticCollections(1);

            // assert
            Assert.That(result, Is.Null);
        }