public void Machine_Update_DoesUpdate() { InnerResource innerResource = new InnerResource(); innerResource.Name = Guid.NewGuid().ToString(); DbContext.InnerResources.Add(innerResource); DbContext.SaveChanges(); //Act innerResource.Name = Guid.NewGuid().ToString(); innerResource.Update(DbContext); InnerResource dbInnerResource = DbContext.InnerResources.AsNoTracking().First(); List <InnerResource> machinelList = DbContext.InnerResources.AsNoTracking().ToList(); List <InnerResourceVersion> machineVersions = DbContext.InnerResourceVersions.AsNoTracking().ToList(); //Assert Assert.NotNull(dbInnerResource); Assert.NotNull(dbInnerResource.Id); Assert.AreEqual(1, machinelList.Count()); Assert.AreEqual(1, machineVersions.Count()); Assert.AreEqual(innerResource.CreatedAt.ToString(), dbInnerResource.CreatedAt.ToString()); Assert.AreEqual(innerResource.Version, dbInnerResource.Version); Assert.AreEqual(innerResource.UpdatedAt.ToString(), dbInnerResource.UpdatedAt.ToString()); Assert.AreEqual(innerResource.CreatedByUserId, dbInnerResource.CreatedByUserId); Assert.AreEqual(innerResource.UpdatedByUserId, dbInnerResource.UpdatedByUserId); Assert.AreEqual(innerResource.Name, dbInnerResource.Name); }
public async Task Machine_Update_DoesUpdate() { // Arrange InnerResource innerResource = new InnerResource { Name = Guid.NewGuid().ToString() }; DbContext.InnerResources.Add(innerResource); DbContext.SaveChanges(); //Act InnerResource selectedInnerResource = new InnerResource { Name = Guid.NewGuid().ToString(), Id = innerResource.Id }; await selectedInnerResource.Update(DbContext); InnerResource dbInnerResource = DbContext.InnerResources.AsNoTracking().First(); List <InnerResource> innerResourceList = DbContext.InnerResources.AsNoTracking().ToList(); List <InnerResourceVersion> versionList = DbContext.InnerResourceVersions.AsNoTracking().ToList(); //Assert Assert.NotNull(dbInnerResource); Assert.AreEqual(1, innerResourceList.Count()); Assert.AreEqual(1, versionList.Count()); Assert.AreEqual(selectedInnerResource.Name, dbInnerResource.Name); }
public async Task Machine_UpdateBinding_DoesUpdate() { // Arrange InnerResource innerResource = new InnerResource { Name = Guid.NewGuid().ToString() }; OuterResource area = new OuterResource { Name = Guid.NewGuid().ToString() }; DbContext.InnerResources.Add(innerResource); DbContext.OuterResources.Add(area); DbContext.SaveChanges(); //Act InnerResource selectedInnerResource = new InnerResource { Name = Guid.NewGuid().ToString(), Id = innerResource.Id, OuterInnerResources = new List <Microting.eFormOuterInnerResourceBase.Infrastructure.Data.Entities.OuterInnerResource>() { new Microting.eFormOuterInnerResourceBase.Infrastructure.Data.Entities.OuterInnerResource() { OuterResourceId = area.Id, InnerResourceId = innerResource.Id } } }; await selectedInnerResource.Update(DbContext); //Assert Assert.AreEqual(selectedInnerResource.OuterInnerResources.First().OuterResourceId, area.Id); }