Example #1
0
        public void GetBucketList_Return_Exeption()
        {
            // Arrange
            var mockDb     = new Mock <IDataBaseManager>();
            var mockLogger = new Mock <ILogger>();

            List <AllToysRequest> allToysRequest = new List <AllToysRequest>();
            int price = 3;

            allToysRequest.Add(new AllToysRequest {
                ID = 1, Name = "Belka", Price = 1
            });
            BacketResponce backetResponce = new BacketResponce()
            {
                ToysData = allToysRequest, Price = price
            };

            mockDb.Setup(db => db.GetBucketListBacketData(It.IsAny <int>())).Throws(new Exception());
            mockDb.Setup(db => db.GetBucketListPrice(It.IsAny <int>())).Throws(new Exception());
            mockLogger.Setup(db => db.Error(It.IsAny <string>()));

            var manager = new BacketManager(mockDb.Object, mockLogger.Object);

            // Act
            var result = manager.GetBucketList(1);

            // Assert
            Assert.IsNull(result);
        }
Example #2
0
        public void GetBucketList_Return_BacketResponce()
        {
            // Arrange
            var mockDb     = new Mock <IDataBaseManager>();
            var mockLogger = new Mock <ILogger>();

            List <AllToysRequest> allToysRequest = new List <AllToysRequest>();
            int price = 3;

            allToysRequest.Add(new AllToysRequest {
                ID = 1, Name = "Belka", Price = 1
            });
            BacketResponce backetResponce = new BacketResponce()
            {
                ToysData = allToysRequest, Price = price
            };

            mockDb.Setup(db => db.GetBucketListBacketData(It.IsAny <int>())).Returns(allToysRequest);
            mockDb.Setup(db => db.GetBucketListPrice(It.IsAny <int>())).Returns(price);
            mockLogger.Setup(db => db.Error(It.IsAny <string>()));

            var manager = new BacketManager(mockDb.Object, mockLogger.Object);

            // Act
            var result = manager.GetBucketList(1);

            // Assert
            Assert.AreEqual(backetResponce.Price, result.Price);
            Assert.AreEqual(backetResponce.ToysData.First(), result.ToysData.First());
        }