public void PlanetIDDoesntExist() { var planetRepository = new Mock <IPlanetRepository>(); var job = new BuildBuildingsJob(planetRepository.Object, null); job.Run(); planetRepository.Verify(pr => pr.Get(It.IsAny <int>()), Times.Never()); planetRepository.Verify(pr => pr.SaveChanges(), Times.Never()); }
public void BuildingCountDoesntExist() { var planetRepository = new Mock <IPlanetRepository>(); var playerRepository = new Mock <IPlayerRepository>(); playerRepository.Setup(pr => pr.Get(It.IsAny <int>())).Returns(new Player()); var job = new BuildBuildingsJob(planetRepository.Object, playerRepository.Object) { PlanetID = 1, PlayerID = 1 }; job.Run(); planetRepository.Verify(pr => pr.Get(It.IsAny <int>()), Times.Once()); planetRepository.Verify(pr => pr.SaveChanges(), Times.Never()); }
public void WillBuildBuildings() { var planetRepository = new Mock <IPlanetRepository>(); var playerRepository = new Mock <IPlayerRepository>(); planetRepository.Setup(pr => pr.Get(It.IsAny <int>())).Returns(new Planet()); playerRepository.Setup(pr => pr.Get(It.IsAny <int>())).Returns(new Player { TotalNetValue = new NetValue() }); var job = new BuildBuildingsJob(planetRepository.Object, playerRepository.Object) { PlanetID = 1, PlayerID = 1, BuildingCount = 1 }; job.Run(); planetRepository.Verify(pr => pr.Get(It.IsAny <int>()), Times.Once()); playerRepository.Verify(pr => pr.Get(It.IsAny <int>()), Times.Once()); planetRepository.Verify(pr => pr.SaveChanges(), Times.Once()); }