Ejemplo n.º 1
0
 private JsonResult RequestReadWrite(Artist artist)
 {
     Guid correlationId = Guid.NewGuid();
     MvcApplication.CommandExecutor.ExecuteCommand(new CreateReadWriteToken() { ArtistId = artist.Id, CorrelationId = correlationId });
     var token = _tokenRepository.GetByCorrelationId(correlationId);
     return Json(_mapper.Map<ApiSessionViewModel>(token), JsonRequestBehavior.AllowGet);
 }
Ejemplo n.º 2
0
        public static UserLogin Create(string username, string password, Artist artist = null)
        {
            var userLogin = new UserLogin(username, password);

            if(artist != null) userLogin.AddArtist(artist);
            return userLogin;
        }
        public void RepositoryGetArtistById()
        {
            const int expectedId = 3;
            var expected = new Artist { Id = expectedId, Name = "WWWW", Country = "WEE", Identifier = "dfr" };

            var data = new List<Artist>{
                expected,
                new Artist{Id = 1, Name = "Ronald", Country = "ZW", Identifier = "abc", Eliases = new List<Elias>{new Elias {Id = 1, EliasName = "Ron", ArtistId = 1}}},
                new Artist{Id = 2, Name = "Zebra", Country = "SA", Identifier = "bvf", Eliases = new List<Elias>{new Elias {Id = 2, EliasName = "Zeb", ArtistId = 2}}}
            }.AsQueryable();

            var mockSet = new Mock<DbSet<Artist>>();
            mockSet.As<IQueryable<Artist>>().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As<IQueryable<Artist>>().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As<IQueryable<Artist>>().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As<IQueryable<Artist>>().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var mockContext = new Mock<BEContext>();
            mockContext.Setup(m => m.Artists).Returns(mockSet.Object);
            mockContext.Setup(m => m.Set<Artist>()).Returns(mockSet.Object);

            var repo = new Repository<Artist>(mockContext.Object);

            var list = repo.GetArtistById(expectedId);

            Assert.AreEqual(1, list.Id);
        }
Ejemplo n.º 4
0
 public static FlickrInfo Create(Artist artist, string requestToken, string requestSecret)
 {
     return new FlickrInfo()
                {
                    IsConnected = false,
                    RequestSecret = requestSecret,
                    RequestToken = requestToken
                };
 }
Ejemplo n.º 5
0
        public static LastFmInfo Create(Artist artist, string name, string bio)
        {
            var lastFmInfo = new LastFmInfo()
                                 {
                                     AssociatedArtist = artist
                                 };

            lastFmInfo.Update(name, bio);
            return lastFmInfo;
        }
Ejemplo n.º 6
0
 public static ApiToken ReadWrite(Artist associatedArtist, Guid correlationId)
 {
     return new ApiToken()
     {
         AssociatedArtist = associatedArtist,
         Created = DateTime.Now,
         Expires = DateTime.Now.AddHours(1),
         IsAuthenticated = true,
         Token = Guid.NewGuid().ToString("N"),
         CorrelationId = correlationId
     };
 }
Ejemplo n.º 7
0
 public void AddArtist(Artist artist)
 {
     if (Artists == null) Artists = new Collection<Artist>();
     Artists.Add(artist);
 }