public void CalculatePackageCost() { var package = new Package { Id = 1, Width = 10, Height = 10, Length = 10, Weight = 10 }; var mockContext = new Mock <InstantDeliveryContext>(); mockContext.Setup(c => c.Packages).ReturnsDbSet(package); var pricingStrategyMock = new Mock <IPricingStrategy>(); pricingStrategyMock.Setup(m => m.GetCost(It.IsAny <PackageDto>())).Returns(0.750M); var controller = new PackagesController(mockContext.Object, pricingStrategyMock.Object); var result = controller.GetPackageCost(Mapper.Map <PackageDto>(package)) as OkNegotiatedContentResult <decimal>; Assert.Equal(result?.Content, 0.750M); }