AllReady.UnitTest.Areas.Admin.Features.Requests.ChangeRequestStatusCommandHandlerShould.LoadTestData C# (CSharp) Method

LoadTestData() protected method

protected LoadTestData ( ) : void
return void
        protected override void LoadTestData()
        {
            var req1 = new Request
            {
                RequestId = _existingRequestId1,
                Name = "New Request 1",
                Status = RequestStatus.Assigned
            };

            var req2= new Request
            {
                RequestId = _existingRequestId2,
                Name = "New Request 2",
                Status = RequestStatus.Completed
            };

            Context.Requests.Add(req1);
            Context.Requests.Add(req2);
            Context.SaveChanges();

            // We must do this so that the context change tracker is not already tracking the item when we come to attach it from out subject under test
            Context.Entry(req1).State = EntityState.Detached;
            Context.Entry(req2).State = EntityState.Detached;
        }