public void CalculateWithValidCommission() { var context = new Mock <ISalesContext>(); var salesmanBLL = new SalesmanBLL(context.Object); var doubleFake = new List <Package> { new Package { PackageId = 1, PackageItems = new List <PackageItem> { new PackageItem { Item = new Item { Category = 0, Price = 34, Type = (int)ItemType.AirplaneTicket } }, new PackageItem { Item = new Item { Category = 0, Price = 34, Type = (int)ItemType.Hotel } }, new PackageItem { Item = new Item { Category = 0, Price = 34, Type = (int)ItemType.Carrental } }, } }, new Package { PackageId = 2, PackageItems = new List <PackageItem> { new PackageItem { Item = new Item { Category = 0, Price = 34, Type = (int)ItemType.AirplaneTicket } }, new PackageItem { Item = new Item { Category = 0, Price = 34, Type = (int)ItemType.Hotel } }, new PackageItem { Item = new Item { Category = 0, Price = 34, Type = (int)ItemType.Carrental } }, } } }; var calculateMock = createDbSetMock <Package>(doubleFake); context.Setup(x => x.Packages).Returns(calculateMock.Object); var result = salesmanBLL.Calculate(2, 3, 5, new List <int> { 1, 2 }); Assert.IsType <double>(result); }
public void CalculatewithInvalidOperationException() { var context = new Mock <ISalesContext>(); var salesmanBLL = new SalesmanBLL(context.Object); var calculateMock = new Mock <DbSet <Package> >(); context.Setup(x => x.Packages).Returns(calculateMock.Object); var result = Assert.Throws <InvalidOperationException>(() => salesmanBLL.Calculate(4, 3, 20, new List <int>())); Assert.Equal("Error! you must enter valid data", result.Message); }