0
から値を返しません。私のTestMethod
からこのメソッドを呼び出すと、RoomServiceRepository
はroomServiceを返しません。私のtestMethodは次のようになります:リポジトリは、私はユニットテストで新たなんだと私は私のサービスの以下の方法のためのユニットテストを書くことをしようとしている私の試験方法
[TestClass]
public class InventoryTest
{
private UnityContainer _container;
readonly MockObjectsSetup _mos = new MockObjectsSetup();
private IInventoryService _inventoryService;
[TestInitialize]
public void SetupTest()
{
_container = new UnityContainer();
_mos.Setup(_container);
Config.UnityTestConfig.RegisterTypes(_container);
_container.RegisterType<IInventoryService, InventoryService>();
_inventoryService = (InventoryService)_container.Resolve(typeof(InventoryService));
}
[TestMethod]
public void Dont_Change_NotSelected_PriceValues()
{
DateTime startDate = DateTime.Parse("6/21/2016");
DateTime endDate = DateTime.Parse("6/22/2016");
long roomServiceId = 17;
InventoryViewModel invViewModel = new InventoryViewModel();
invViewModel.isUpdatingBoardPrice = invViewModel.isUpdatingPrice = invViewModel.isUpdatingFloatAvailability = true;
invViewModel.isUpdatingCertainAvailability = false;
invViewModel.StartDate = startDate;
invViewModel.EndDate = endDate;
invViewModel.RoomServiceId = roomServiceId;
invViewModel.CertainAvailability = 0;
invViewModel.FloatAvailability = 8;
var inv = _inventoryService.GetInventory(startDate, endDate, roomServiceId);
....
}
}
あなたの 'inventoryService'を嘲笑して例外はありますか? –
私はそれを嘲笑していない、私が言ったように、私は新しく、私はサービスを模擬する方法を知らない。 –