public void CheckIfAddPlayMethodDoesNotAddPlayToTheSameUserThatRequested() { // Arrange var plays = new List <Play>(); var beats = new List <Beat>(); var beatRepo = new Mock <IDeletableEntityRepository <Beat> >(); beatRepo.Setup(b => b.AddAsync(It.IsAny <Beat>())).Callback( (Beat beat) => beats.Add(beat)); beatRepo.Setup(b => b.All()).Returns(beats.AsQueryable()); var playRepo = new Mock <IRepository <Play> >(); playRepo.Setup(p => p.AddAsync(It.IsAny <Play>())).Callback( (Play play) => plays.Add(play)); playRepo.Setup(r => r.All()).Returns(plays.AsQueryable()); var likeRepo = new Mock <IDeletableEntityRepository <Like> >(); var beatService = new BeatService(beatRepo.Object, playRepo.Object, likeRepo.Object); // Act beatService.CreateAsync("test", "test", "test", 10, Genre.Rock.ToString(), 112, "test", "user").GetAwaiter(); beatService.AddPlay(0, "user").GetAwaiter(); // Assert Assert.Empty(plays); }
public void CheckIfUserCannotEditOtherUserBeat() { var plays = new List <Play>(); var beats = new List <Beat>(); var beatRepo = new Mock <IDeletableEntityRepository <Beat> >(); beatRepo.Setup(b => b.AddAsync(It.IsAny <Beat>())).Callback( (Beat beat) => beats.Add(beat)); beatRepo.Setup(b => b.All()).Returns(beats.AsQueryable()); var playRepo = new Mock <IRepository <Play> >(); var likeRepo = new Mock <IDeletableEntityRepository <Like> >(); var beatService = new BeatService(beatRepo.Object, playRepo.Object, likeRepo.Object); beatService.CreateAsync("test", "test", "test", 10, Genre.Rock.ToString(), 112, "test", "user").GetAwaiter(); beatService.UpdateAsync("anotherUser", 0, "hack", 100, Genre.HipHop.ToString(), 120, "hack").GetAwaiter(); Assert.Equal("test", beats.First().Name); }