Пример #1
0
        public void Update_Status_From_Defaults()
        {
            // arrange
            var newStatus = new Status()
            {
                Title = "Sample Status"
            };

            Context.Statuses.Add(newStatus);
            Context.SaveChanges();

            Status oldStatus = Context.Statuses.First(e => e.Title == "Sample Status");

            oldStatus.Title = "New Status";

            var oldId = oldStatus.Id;

            //act
            Context.Entry(oldStatus).State = EntityState.Modified;
            Context.SaveChanges();

            //assert
            Status modifiedStatus = Context.Statuses.Find(oldId);

            modifiedStatus.Title.ShouldBe("New Status");
        }
Пример #2
0
        public ActionResult PutCapstone([Required] int UserId, [Required] int capstoneId, [FromBody, Required] Capstone capstone)
        {
            if (capstoneId != capstone.CapstoneId)
            {
                return(BadRequest());
            }

            _capstoneContext.Entry(capstone).State = EntityState.Modified;

            try
            {
                _capstoneContext.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!capstoneRepository.CapstoneExists(capstoneId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }


            return(Ok());
        }
Пример #3
0
        public void Update_EventType_From_Defaults()
        {
            // arrange
            var newEventType = new EventType()
            {
                Title = "Sample Status"
            };

            Context.EventType.Add(newEventType);
            Context.SaveChanges();

            EventType oldEventType = Context.EventType.First(e => e.Title == "Sample Status");

            oldEventType.Title = "New Status";

            var oldId = oldEventType.Id;

            //act
            Context.Entry(oldEventType).State = EntityState.Modified;
            Context.SaveChanges();

            //assert
            EventType modifiedEventType = Context.EventType.Find(oldId);

            modifiedEventType.Title.ShouldBe("New Status");
        }
        public void Update_Event_From_Defaults()
        {
            // arrange
            Context.Events.Add(_sampleEvent);
            Context.SaveChanges();

            Event oldEvent = Context.Events.First(e => e.Title == "Sample Event");

            oldEvent.Title               = "New Title";
            oldEvent.Description         = "New Description";
            oldEvent.StartDateTime       = new DateTime(2015, 4, 28);
            oldEvent.EndDateTime         = new DateTime(2015, 4, 28);
            oldEvent.LocationInformation = "none";
            oldEvent.LogoPath            = "http://fake/image";

            var oldId = oldEvent.Id;

            //act
            Context.Entry(oldEvent).State = EntityState.Modified;
            Context.SaveChanges();

            //assert
            Event modifiedEvent = Context.Events.Find(oldId);

            modifiedEvent.ShouldSatisfyAllConditions(
                () => modifiedEvent.Title.ShouldBe("New Title"),
                () => modifiedEvent.Description.ShouldBe("New Description"),
                () => modifiedEvent.StartDateTime.ShouldBe(new DateTime(2015, 4, 28)),
                () => modifiedEvent.EndDateTime.ShouldBe(new DateTime(2015, 4, 28)),
                () => modifiedEvent.LocationInformation.ShouldBe("none"),
                () => modifiedEvent.LogoPath.ShouldBe("http://fake/image")
                )
            ;
        }
        public void Update_Registration_From_Defaults()
        {
            // arrange
            var newEvent = new Event
            {
                Title               = "Sample Event",
                Description         = "Sample Event Description",
                StartDateTime       = DateTime.Now,
                EndDateTime         = DateTime.Now.AddHours(1),
                RegistrationType    = new RegistrationType(),
                Registrations       = new List <Registration>(),
                EventType           = new EventType(),
                Status              = new Status(),
                LocationInformation = "At some new location",
                LogoPath            = "http://google/someimage"
            };

            Context.Events.Add(newEvent);
            Context.SaveChanges();

            var newRegistration = new Registration()
            {
                Event            = newEvent,
                EventType        = new EventType(),
                RegisterDateTime = DateTime.Now,
                Title            = "A title"
            };

            //act
            Context.Registrations.Add(newRegistration);
            Context.SaveChanges();

            Registration oldRegistration = Context.Registrations.First(r => r.Title == "A title");
            var          oldId           = oldRegistration.Id;

            oldRegistration.Title            = "New Title";
            oldRegistration.RegisterDateTime = new DateTime(2015, 4, 28);

            Context.Entry(oldRegistration).State = EntityState.Modified;
            Context.SaveChanges();

            //assert
            Registration modifiedRegistration = Context.Registrations.Find(oldId);

            modifiedRegistration.Title.ShouldBe("New Title");
            modifiedRegistration.RegisterDateTime.ShouldBe(new DateTime(2015, 4, 28));
        }