public void Stars_WithExistingDiscoveryId_ShouldReturnStars() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); const int discoveryId = 1; Discovery discovery = new Discovery { Id = discoveryId, Stars = this.GetFakeStars() }; db.Discoveries.Add(discovery); db.SaveChanges(); List <Star> fakeStars = this.GetFakeStars(); int i = -1; // Act IEnumerable <ListStarsServiceModel> stars = starService.Stars(discoveryId).OrderBy(s => s.Id); // Assert foreach (var actual in stars) { Star expected = fakeStars[++i]; this.CompareStars(expected, actual); } }
protected void getDependencies(ServiceManager serviceManager) { starService = serviceManager.get <StarService>() as StarService; playerAdapter = serviceManager.get <PlayerAdapter>() as PlayerAdapter; eventManager = serviceManager.get <EventManager>() as EventManager; mainServer = serviceManager.get <MainServer>() as MainServer; }
protected void OnLoginSuccessful(LoginSuccessfulEvent e) { StarService starService = application.serviceManager.get <StarService>() as StarService; StarModel currentStar = starService.GetStarByName(e.player.currentNodeName); welcomeText.text = "Welcome to " + currentStar.name; }
public void GetAllMoviesOfStar_ShouldReturnCorrectMovies_WhenValidParametersPassed() { var firstName = "Natalie"; var lastName = "Portman"; var starRepositoryMock = new Mock <IRepository <Star> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var starFactoryMock = new Mock <IStarFactory>(); var star = new Star(firstName, lastName, null, null); var list = new List <Star>() { star }; var queryableStars = list.AsQueryable(); starRepositoryMock.Setup(r => r.Entities).Returns(queryableStars); var movies = new List <Movie>() { new Movie("Fast And Furious", 2001, null, 112, null, null, null, null, null), new Movie("Fast And Furious 2", 2002, null, 112, null, null, null, null, null) }; star.Movies.Add(movies[0]); star.Movies.Add(movies[1]); var starService = new StarService( starRepositoryMock.Object, unitOfWorkMock.Object, starFactoryMock.Object); var returnedMoves = starService.GetAllMoviesOfStar(firstName, lastName); Assert.AreEqual(movies, returnedMoves); }
void Start() { StarService starService = Infrastructure.Base.Application.Application.getInstance().serviceManager.get <StarService> () as StarService; stars = starService.GetStarsList(); Hide(); }
public ActionResult Index() { var starService = new StarService(); var model = new StarViewModel() { StudioIDs = starService.GetStudios() }; return(View(model)); }
public void GetForm_WithNotExistingId_ShouldReturnNull() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); // Act StarFormServiceModel result = starService.GetForm(1); // Assert Assert.Null(result); }
public void UpdateStar_ShouldCallUnitOfWorkCommitMethod_WhenValidParametersPassed() { var starRepositoryMock = new Mock <IRepository <Star> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var starFactoryMock = new Mock <IStarFactory>(); var starMock = new Mock <Star>(); var starService = new StarService( starRepositoryMock.Object, unitOfWorkMock.Object, starFactoryMock.Object); starService.UpdateStar(starMock.Object); unitOfWorkMock.Verify(n => n.Commit(), Times.Once); }
public void GetStarByName_ShouldCallRepository_WhenValidParametersPassed() { var firstName = "Natalie"; var lastName = "Portman"; var starRepositoryMock = new Mock <IRepository <Star> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var starFactoryMock = new Mock <IStarFactory>(); var starService = new StarService( starRepositoryMock.Object, unitOfWorkMock.Object, starFactoryMock.Object); starService.GetStarByName(firstName, lastName); starRepositoryMock.Verify(r => r.Entities, Times.Once); }
public void CreateStar_ShouldCallUnitOfWorkCommitMethod_WhenValidParametersPassed() { var starRepositoryMock = new Mock <IRepository <Star> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var starFactoryMock = new Mock <IStarFactory>(); var starService = new StarService( starRepositoryMock.Object, unitOfWorkMock.Object, starFactoryMock.Object); var firstName = "Natalie"; var lastName = "Portman"; starService.CreateStar(firstName, lastName, null, null); unitOfWorkMock.Verify(n => n.Commit(), Times.Once); }
public void Exists_WithNotExistingName_ShouldReturnFalse() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); string name = this.GetFakeStars().First().Name; // Act bool result = starService.Exists(name); // Assert Assert.False(result); }
public void Delete_LastStar_ShouldReturnFalse() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); this.SeedDiscovery(db, 1); // Act bool result = starService.Delete(1); // Assert Assert.False(result); }
public void Stars_WithNotExistingDiscoveryId_ShouldReturnEmptyCollection() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); const int discoveryId = 1; // Act IEnumerable <ListStarsServiceModel> stars = starService.Stars(discoveryId); // Assert Assert.False(stars.Any()); }
public void Delete_WithNotExistingId_ShouldReturnFalse() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); int starsCount = this.GetFakeStars().Count; this.SeedDiscovery(db, starsCount); // Act bool result = starService.Delete(starsCount + 1); // Assert Assert.False(result); }
public void Delete_WithExistingId_ShouldReturnTrue() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); this.SeedDiscovery(db, 2); const int starId = 1; // Act bool result = starService.Delete(starId); // Assert Assert.True(result); }
public void Delete_WithNotExistingId_ShouldNotRemoveStar() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); int starsCount = this.GetFakeStars().Count; this.SeedDiscovery(db, starsCount); // Act starService.Delete(11); // Assert Assert.Equal(starsCount, db.Stars.Count()); }
public void GetName_WithExistingId_ShouldReturnValidName() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); this.SeedDatabase(db); Star star = this.GetFakeStars().First(); // Act string actual = starService.GetName(star.Id); // Assert Assert.Equal(star.Name, actual); }
public void DeleteStar_ShouldThrowNullReferenceException_WhenStarIsNotFound() { var firstName = "Natalie"; var lastName = "Portman"; var starRepositoryMock = new Mock <IRepository <Star> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var starFactoryMock = new Mock <IStarFactory>(); var list = new List <Star>(); var queryableStars = list.AsQueryable(); starRepositoryMock.Setup(r => r.Entities).Returns(queryableStars); var starService = new StarService( starRepositoryMock.Object, unitOfWorkMock.Object, starFactoryMock.Object); Assert.Throws <NullReferenceException>(() => starService.DeleteStar(firstName, lastName)); }
public void Create_WithNotExistingDeiscovery_ShouldReturnFalse() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); const int discoveryId = 1; Star expected = this.GetFakeStars().First(); // Act bool result = starService.Create(discoveryId, expected.Name, expected.Temperature); // Assert Assert.False(result); }
public void Edit_WithNotExistingId_ShouldReturnFalse() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); const int starId = 1; Star star = this.GetFakeStars().First(); // Act bool result = starService.Edit(starId, star.Name, star.Temperature); // Assert Assert.False(result); }
public void AddStars_ShouldCallRepositoryAddMethod_WhenValidListIsPassed() { var starRepositoryMock = new Mock <IRepository <Star> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var starFactoryMock = new Mock <IStarFactory>(); var starService = new StarService( starRepositoryMock.Object, unitOfWorkMock.Object, starFactoryMock.Object); var stars = new List <Star> { new Star("Natalie", "Portman", null, null), new Star("Tom", "Cruise", null, null) }; starService.AddStars(stars); starRepositoryMock.Verify(r => r.Add(It.IsAny <Star>()), Times.Exactly(stars.Count)); }
public void AddStars_ShouldCallUnitOfWorkCommitMethod_WhenValidListIsPassed() { var starRepositoryMock = new Mock <IRepository <Star> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var starFactoryMock = new Mock <IStarFactory>(); var starService = new StarService( starRepositoryMock.Object, unitOfWorkMock.Object, starFactoryMock.Object); var stars = new List <Star> { new Star("Natalie", "Portman", null, null), new Star("Tom", "Cruise", null, null) }; starService.AddStars(stars); unitOfWorkMock.Verify(n => n.Commit(), Times.Once); }
public void CreateStar_ShouldReturnCorrectStar_WhenValidParametersPassed() { var starRepositoryMock = new Mock <IRepository <Star> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var starFactoryMock = new Mock <IStarFactory>(); var starService = new StarService( starRepositoryMock.Object, unitOfWorkMock.Object, starFactoryMock.Object); var firstName = "Natalie"; var lastName = "Portman"; var star = new Star(firstName, lastName, null, null); starFactoryMock.Setup(f => f.CreateStar(firstName, lastName, null, null)).Returns(star); var returnedStar = starService.CreateStar(firstName, lastName, null, null); Assert.AreSame(star, returnedStar); }
public void GetForm_WithExistingId_ShouldReturnStar() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); this.SeedDatabase(db); const int starId = 1; Star expected = this.GetFakeStars().First(); // Act StarFormServiceModel actual = starService.GetForm(starId); // Assert this.CompareStars(expected, actual); }
public void Delete_WithExistingId_ShouldRemoveStar() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); int starsCount = this.GetFakeStars().Count; int starId = 1; this.SeedDiscovery(db, starsCount); // Act starService.Delete(starId); Star star = db.Stars.Find(starId); // Assert Assert.Null(star); Assert.Equal(starsCount - 1, db.Stars.Count()); }
public void Create_WithNotExistingName_ShouldReturnTrue() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); const int discoveryId = 1; this.SeedDiscovery(db); Star star = this.GetFakeStars().First(); // Act bool result = starService.Create(discoveryId, star.Name, star.Temperature); // Assert Assert.True(result); }
public void Create_WithDiscoveryWithMaxStars_ShouldReturnFalse() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); const int discoveryId = 1; this.SeedDiscovery(db, 3); Star star = this.GetFakeStars().FirstOrDefault(s => s.Id == 4); // Act bool result = starService.Create(discoveryId, star.Name, star.Temperature); // Assert Assert.False(result); }
public void CreatStar_ShouldCallRepositoryAddMethod_WhenValidParametersPassed() { var starRepositoryMock = new Mock <IRepository <Star> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var starFactoryMock = new Mock <IStarFactory>(); var starService = new StarService( starRepositoryMock.Object, unitOfWorkMock.Object, starFactoryMock.Object); var firstName = "Natalie"; var lastName = "Portman"; var star = new Star(firstName, lastName, null, null); starFactoryMock.Setup(f => f.CreateStar(firstName, lastName, null, null)).Returns(star); starService.CreateStar(firstName, lastName, null, null); starRepositoryMock.Verify(r => r.Add(star), Times.Once); }
public void Edit_WithSameName_ShouldReturnTrue() { // Arrange StarStuffDbContext db = this.Database; StarService starService = new StarService(db); this.SeedDatabase(db); Star star = this.GetFakeStars().First(); star.Temperature = 111111; // Act bool result = starService.Edit(star.Id, star.Name, star.Temperature); // Assert Assert.True(result); }
public ActionResult StarBoard(int studioid) { var starService = new StarService(); try { var stars = starService.GetClientVisits("", "", studioid); var model = new StarBoardViewModel() { Stars = stars }; return(View(model)); } catch (Exception e) { return(RedirectToAction("StudioNotSetup", new { message = e.Message })); } }