public void TestCreateRace() { using (raceRepository) { var track = new Track() { BestTime = 121213123, LengthInMeters = 123214, MaxCars = 50, Name = "RaceTrack" }; context.Add(track); context.SaveChanges(); var raceDTO = new RaceCreateDTO() { ActualEnd = new DateTime(1920, 11, 11), ActualStart = new DateTime(1920, 11, 11), NumberOfLaps = 5, PlannedEnd = new DateTime(1920, 11, 11), PlannedStart = new DateTime(1920, 11, 11), TrackId = track.Id }; Assert.NotNull(context.Races.Find(raceRepository.Create(raceDTO))); } }
public void Create_New_Car_In_Create_Race_Repo() { var race = default(Race); var dto = new RaceCreateDTO { Id = 1, TrackId = 2, NumberOfLaps = 7 }; var mock = new Mock <ISlotCarContext>(); mock.Setup(s => s.Races.Add(It.IsAny <Race>())) .Callback <Race>(r => race = r); using (var repository = new RaceRepository(mock.Object)) { repository.Create(dto); } if (race != null) { Assert.Equal(1, race.Id); Assert.Equal(2, race.TrackId); Assert.Equal(7, race.NumberOfLaps); } else { Assert.True(true); } }