public void GivenRoomCreated_WhenLessThanZeroUnits_ThenInvalidOperationException() { //Given var rooms = new RoomTypes(); //When object[] events = null; TestDelegate when = () => events = rooms.Create(Guid.NewGuid(), Guid.NewGuid(), "Single", -1).ToArray(); //Then var ex = Assert.Throws <InvalidOperationException>(when); Assert.That(events, Is.Null); Assert.That(ex.Message, Is.EqualTo("Must have zero or more rooms in inventory.")); }
public void GivenRoomCreated_WhenRoomTypeBlank_ThenInvalidOperationException() { //Given var rooms = new RoomTypes(); //When object[] events = null; TestDelegate when = () => events = rooms.Create(Guid.NewGuid(), Guid.NewGuid(), "", 1).ToArray(); //Then var ex = Assert.Throws <InvalidOperationException>(when); Assert.That(events, Is.Null); Assert.That(ex.Message, Is.EqualTo("Room type must not be blank.")); }
public void GivenRoomCreated_WhenAlreadyExists_ThenInvalidOperationException() { //Given var rooms = new RoomTypes(); rooms.Hydrate(new RoomsCreated(Guid.NewGuid(), "RoomTypeId", 1, Guid.NewGuid())); //When object[] events = null; TestDelegate when = () => events = rooms.Create(Guid.NewGuid(), Guid.NewGuid(), "RoomTypeId", 1).ToArray(); //Then var ex = Assert.Throws <InvalidOperationException>(when); Assert.That(events, Is.Null); Assert.That(ex.Message, Is.EqualTo("Room type already created.")); }
public void WhenCreate_ThenRoomsCreated() { //Given var rooms = new RoomTypes(); //When var roomCategoryId = Guid.NewGuid(); var hotelId = Guid.NewGuid(); const string roomTypeName = "Double"; var events = rooms.Create(hotelId, roomCategoryId, roomTypeName, 1).ToArray(); //Then Assert.That(events, Has.Length.EqualTo(1)); Assert.That(events[0], Is.TypeOf <RoomsCreated>()); var roomsCreated = (RoomsCreated)events[0]; Assert.That(roomsCreated.RoomTypeId, Is.EqualTo(roomCategoryId)); Assert.That(roomsCreated.HotelId, Is.EqualTo(hotelId)); Assert.That(roomsCreated.RoomType, Is.EqualTo(roomTypeName)); Assert.That(roomsCreated.NoOfUnits, Is.EqualTo(1)); }