Пример #1
0
        public void NotifyUser()
        {
            var exhibitCommand = new Create.Command
            {
                GenreId  = 1,
                UserId   = "id",
                Location = "aperture gallery",
                DateTime = DateTime.Today,
                ImageUrl = "url"
            };
            var exhibit = Exhibit.Create(exhibitCommand);

            var user = new ApplicationUser
            {
                Email    = _testUsername,
                Name     = _testName,
                ImageUrl = _testImageUrl
            };

            var notification = Notification.ExhibitCreated(exhibit);

            user.Notify(notification);
            var userNotification = user.UserNotifications.SingleOrDefault();

            Assert.Equal(_testName, userNotification.User.Name);
        }
Пример #2
0
        public async Task Should_return_all_exhibits()
        {
            var exhibitCommand = new Create.Command
            {
                GenreId  = 1,
                UserId   = "id",
                Location = "aperture gallery",
                DateTime = DateTime.Today,
                ImageUrl = "url"
            };

            var exhibit = Exhibit.Create(exhibitCommand);

            var attendanceCommand = new Attend.Command
            {
                UserId    = _attendeeId,
                ExhibitId = _exhibitId
            };

            var attendance = Attendance.Create(attendanceCommand);

            exhibit.AddAttendance(attendance);

            await InsertAsync(exhibit);

            var result = await SendAsync(new Index.Query());

            result.ShouldNotBeNull();
        }
Пример #3
0
        public void ExhibitCanceled()
        {
            var exhibitCommand = new Create.Command
            {
                GenreId  = 1,
                UserId   = "id",
                Location = "aperture gallery",
                DateTime = DateTime.Today,
                ImageUrl = _testImageUrl
            };
            var exhibit = Exhibit.Create(exhibitCommand);

            exhibit.Cancel();

            Assert.Equal(_testCanceled, exhibit.IsCanceled);
        }
Пример #4
0
            public async Task Handle(Command message)
            {
                var uploadPath = Path.Combine(_environment.WebRootPath, "images/exhibits");
                var ImageName  = ContentDispositionHeaderValue.Parse(message.ImageUpload.ContentDisposition).FileName.Trim('"');

                using (var fileStream = new FileStream(Path.Combine(uploadPath, message.ImageUpload.FileName), FileMode.Create))
                {
                    await message.ImageUpload.CopyToAsync(fileStream);

                    message.ImageUrl = "http://exhibitbaseurl/images/exhibits/" + ImageName;
                }
                message.DateTime = DateTime.Parse(string.Format("{0}", message.Date));

                var exhibit = Exhibit.Create(message);

                _repository.Add(exhibit);
                _repository.SaveAll();
            }
Пример #5
0
        public void ExhibitUpdated()
        {
            var exhibitCommand = new Create.Command
            {
                GenreId  = 1,
                UserId   = "id",
                Location = _testLocation,
                DateTime = DateTime.Today,
                ImageUrl = _testImageUrl
            };
            var exhibit = Exhibit.Create(exhibitCommand);

            exhibit.ManagerUpdate(
                _testNewLocation,
                DateTime.Today,
                _testNewImageUrl);

            Assert.Equal(_testNewImageUrl, exhibit.ImageUrl);
        }
Пример #6
0
        public void UpdatedExhibitNotification()
        {
            var exhibitCommand = new Create.Command
            {
                GenreId  = 1,
                UserId   = "id",
                Location = "aperture gallery",
                DateTime = DateTime.Today,
                ImageUrl = "url"
            };
            var user = new ApplicationUser
            {
                Email    = _testUsername,
                Name     = _testName,
                ImageUrl = _testImageUrl
            };
            var exhibit      = Exhibit.Create(exhibitCommand);
            var notification = Notification.ExhibitUpdated(exhibit, _testOriginalDateTime, _testOriginalLocation);

            Assert.Equal(_testNotificationType, notification.Type);
        }
Пример #7
0
        public void SuspendUser()
        {
            var exhibitCommand = new Create.Command
            {
                GenreId  = 1,
                UserId   = "id",
                Location = "aperture gallery",
                DateTime = DateTime.Today,
                ImageUrl = "url"
            };
            var user = new ApplicationUser
            {
                Email    = _testUsername,
                Name     = _testName,
                ImageUrl = _testImageUrl
            };
            var exhibit      = Exhibit.Create(exhibitCommand);
            var notification = Notification.ExhibitCreated(exhibit);

            user.Suspend();

            Assert.Equal(_testIsSuspended, user.IsSuspended);
        }
Пример #8
0
        public void DetailsUpdated()
        {
            var exhibitCommand = new Create.Command
            {
                GenreId  = 1,
                UserId   = "id",
                Location = _testLocation,
                DateTime = DateTime.Today,
                ImageUrl = _testImageUrl
            };
            var exhibit = Exhibit.Create(exhibitCommand);

            var exhibitEditCommand = new Edit.Command
            {
                Location = _testNewLocation,
                DateTime = DateTime.Today,
                ImageUrl = _testNewImageUrl
            };

            exhibit.UpdateDetails(exhibitEditCommand);

            Assert.Equal(_testNewImageUrl, exhibit.ImageUrl);
        }
Пример #9
0
        public void IsReadIsTrue()
        {
            var exhibitCommand = new Create.Command
            {
                GenreId  = 1,
                UserId   = "id",
                Location = "aperture gallery",
                DateTime = DateTime.Today,
                ImageUrl = "url"
            };
            var exhibit = Exhibit.Create(exhibitCommand);

            var attendanceCommand = new Attend.Command
            {
                UserId    = _attendeeId,
                ExhibitId = _exhibitId
            };
            var attendance = Attendance.Create(attendanceCommand);

            exhibit.AddAttendance(attendance);

            Assert.Equal(_exhibitId, exhibit.Attendances.SingleOrDefault().ExhibitId);
            Assert.Equal(_attendeeId, exhibit.Attendances.SingleOrDefault().AttendeeId);
        }