Beispiel #1
0
        void Deletes_Range_of_Documents_With_Composite_PK()
        {
            int INSERT_QTY = 100;
            var bulkList   = new List <BuildingDocument>();

            for (int i = 1; i <= INSERT_QTY; i++)
            {
                var newBuildingDocument = new BuildingDocument {
                    PropertyId = 1,
                    BuildingId = i,
                    Name       = "Building " + i
                };
                bulkList.Add(newBuildingDocument);
            }
            buildingDocs.Add(bulkList);

            var inserted      = buildingDocs.Load();
            int insertedCount = inserted.Count;

            var deleteUs = inserted.Where(b => b.BuildingId > 50);

            buildingDocs.Remove(deleteUs.ToList());
            var remaining = buildingDocs.Load();

            Assert.True(insertedCount > remaining.Count && remaining.Count == 50);
        }
 public void CreateBuildingDocuments(BuildingDocument buildingDocument)
 {
     using (var unitOfWork = new UnitOfWork())
     {
         unitOfWork.BuildingDocumentsRepository.Insert(buildingDocument);
         unitOfWork.BuildingDocumentsRepository.Save();
     }
 }
        public void Adds_Document_With_Composite_PK()
        {
            var newBuilding = new BuildingDocument {
            PropertyId = 1,
            BuildingId = 1,
            Name = "Building 1"
              };

              buildingDocs.Add(newBuilding);
              var fetchBuilding = buildingDocs.Load().First();
              Assert.True(fetchBuilding.Name == "Building 1");
        }
Beispiel #4
0
        public void Adds_Document_With_Composite_PK()
        {
            var newBuilding = new BuildingDocument {
                PropertyId = 1,
                BuildingId = 1,
                Name       = "Building 1"
            };

            buildingDocs.Add(newBuilding);
            var fetchBuilding = buildingDocs.Load().First();

            Assert.True(fetchBuilding.Name == "Building 1");
        }
 public void Deletes_Document_With_Composite_PK()
 {
     var newBuilding = new BuildingDocument {
     PropertyId = 1,
     BuildingId = 1,
     Name = "Building 1"
       };
       buildingDocs.Add(newBuilding);
       // Count after adding new:
       int initialCount = buildingDocs.Load().Count();
       var removed = buildingDocs.Remove(newBuilding);
       // Count after removing and reloading:
       int finalCount = buildingDocs.Load().Count();
       Assert.True(finalCount < initialCount);
 }
Beispiel #6
0
        public void Deletes_Document_With_Composite_PK()
        {
            var newBuilding = new BuildingDocument {
                PropertyId = 1,
                BuildingId = 1,
                Name       = "Building 1"
            };

            buildingDocs.Add(newBuilding);
            // Count after adding new:
            int initialCount = buildingDocs.Load().Count();
            var removed      = buildingDocs.Remove(newBuilding);
            // Count after removing and reloading:
            int finalCount = buildingDocs.Load().Count();

            Assert.True(finalCount < initialCount);
        }
Beispiel #7
0
        void Bulk_Inserts_Documents_With_Serial_PK()
        {
            int INSERT_QTY = 100;
            var bulkList   = new List <BuildingDocument>();

            for (int i = 0; i < INSERT_QTY; i++)
            {
                var newBuildingDocument = new BuildingDocument {
                    PropertyId = 1,
                    BuildingId = i,
                    Name       = "Building " + i
                };
                bulkList.Add(newBuildingDocument);
            }
            buildingDocs.Add(bulkList);

            var inserted = buildingDocs.Load();

            Assert.True(inserted.Count() == INSERT_QTY);
        }
Beispiel #8
0
        public void Updates_Document_With_Composite_PK()
        {
            var newBuilding = new BuildingDocument {
                PropertyId = 1,
                BuildingId = 1,
                Name       = "Building 1"
            };

            buildingDocs.Add(newBuilding);
            int propertyId = newBuilding.PropertyId;
            int buildingId = newBuilding.BuildingId;
            // Go find the new record after reloading:

            var updateMe = buildingDocs.Load().FirstOrDefault(b => b.PropertyId == propertyId && b.BuildingId == buildingId);

            // Update:
            updateMe.Name = "Updated Building 1";
            buildingDocs.Update(updateMe);
            // Go find the updated record after reloading:
            var updated = buildingDocs.Load().FirstOrDefault(b => b.PropertyId == propertyId && b.BuildingId == buildingId);

            Assert.True(updateMe.Name == "Updated Building 1");
        }
        public void Updates_Document_With_Composite_PK()
        {
            var newBuilding = new BuildingDocument {
            PropertyId = 1,
            BuildingId = 1,
            Name = "Building 1"
              };
              buildingDocs.Add(newBuilding);
              int propertyId = newBuilding.PropertyId;
              int buildingId = newBuilding.BuildingId;
              // Go find the new record after reloading:

              var updateMe = buildingDocs.Load().FirstOrDefault(b => b.PropertyId == propertyId && b.BuildingId == buildingId);
              // Update:
              updateMe.Name = "Updated Building 1";
              buildingDocs.Update(updateMe);
              // Go find the updated record after reloading:
              var updated = buildingDocs.Load().FirstOrDefault(b => b.PropertyId == propertyId && b.BuildingId == buildingId);
              Assert.True(updateMe.Name == "Updated Building 1");
        }
        void Deletes_Range_of_Documents_With_Composite_PK()
        {
            int INSERT_QTY = 100;
              var bulkList = new List<BuildingDocument>();
              for (int i = 1; i <= INSERT_QTY; i++) {
            var newBuildingDocument = new BuildingDocument {
              PropertyId = 1,
              BuildingId = i,
              Name = "Building " + i
            };
            bulkList.Add(newBuildingDocument);
              }
              buildingDocs.Add(bulkList);

              var inserted = buildingDocs.Load();
              int insertedCount = inserted.Count;

              var deleteUs = inserted.Where(b => b.BuildingId > 50);
              buildingDocs.Remove(deleteUs.ToList());
              var remaining = buildingDocs.Load();
              Assert.True(insertedCount > remaining.Count && remaining.Count == 50);
        }
        void Bulk_Inserts_Documents_With_Serial_PK()
        {
            int INSERT_QTY = 100;
              var bulkList = new List<BuildingDocument>();
              for (int i = 0; i < INSERT_QTY; i++) {
            var newBuildingDocument = new BuildingDocument {
              PropertyId = 1,
              BuildingId = i,
              Name = "Building " + i
            };
            bulkList.Add(newBuildingDocument);
              }
              buildingDocs.Add(bulkList);

              var inserted = buildingDocs.Load();
              Assert.True(inserted.Count() == INSERT_QTY);
        }