public async Task Can_retrieve_record_using_first_or_Default_asynchronously()
        {
            var configContext = new ConfigurableContext<TestDbContext>(ctx =>
            {
                ctx.Setup(x => x.TestRecords, new TestRecord { Id = 1, Name = "A" }, new TestRecord { Id = 2, Name = "B" });
            });

            var opHelper = new DbOperationsHelper(configContext);

            var result = await opHelper.GetRecordAsync(t => t.Id == 1);

            result.Should().NotBeNull();
            result.Id.Should().Be(1);
            result.Name.Should().Be("A");
        }
        public void Can_retrieve_records_using_where_method()
        {
            var configContext = new ConfigurableContext<TestDbContext>(ctx =>
            {
                ctx.Setup(x => x.TestRecords, new TestRecord { Id = 1, Name = "A" }, new TestRecord { Id = 2, Name = "B" }, new TestRecord { Id = 1, Name = "C" });
            });

            var opHelper = new DbOperationsHelper(configContext);

            var results = opHelper.GetRecords(t => t.Id == 1)?.ToArray();

            results.Should().HaveCount(2);
            results.Should().Contain(t => t.Id == 1 && t.Name == "A");
            results.Should().Contain(t => t.Id == 1 && t.Name == "C");
        }
        public async Task Can_retrieve_records_with_async()
        {
            var configContext = new ConfigurableContext<TestDbContext>(ctx =>
            {
                ctx.Setup(x => x.TestRecords, new TestRecord { Id = 1, Name = "A" }, new TestRecord { Id = 2, Name = "B" }, new TestRecord { Id = 1, Name = "C" });
            });

            var opHelper = new DbOperationsHelper(configContext);

            var results = await opHelper.GetRecordsAsync(t => t.Id == 1);

            results.Should().HaveCount(2);
            results.Should().Contain(t => t.Id == 1 && t.Name == "A");
            results.Should().Contain(t => t.Id == 1 && t.Name == "C");

        }
        public void Can_verify_specific_entity_was_not_saved()
        {
            var testContext = new ConfigurableContext<TestDbContext>(ctx =>
            {
                ctx.Setup(x => x.TestRecords, new TestRecord { Id = 1, Name = "Not Joe"});
            });

            var dbOperationHelper = new DbOperationsHelper(testContext);
            var testRecord = new TestRecord
            {
                Id = 2,
                Name = "Anything"
            };
            dbOperationHelper.CreateInvalidTestRecord(testRecord);

            testContext.HasNotBeenSaved<TestRecord>(x => x.Id == 1 && x.Name == "Anything");
        }
        public void Can_verify_no_entities_of_type_were_saved()
        {
            var testContext = new ConfigurableContext<TestDbContext>(ctx =>
            {
                ctx.Setup(x => x.TestRecords, new List<TestRecord>());
            });

            var dbOperationHelper = new DbOperationsHelper(testContext);
            var testRecord = new TestRecord
            {
                Id = 1,
                Name = "Anything"
            };
            dbOperationHelper.CreateInvalidTestRecord(testRecord);

            testContext.HasNotBeenSaved<TestRecord>();
        }
        public void Can_verify_new_entity_has_been_saved_with_correct_properties()
        {
            var testContext = new ConfigurableContext<TestDbContext>(ctx =>
            {
                ctx.Setup(x => x.TestRecords, new List<TestRecord>());
            });

            var dbOperationHelper = new DbOperationsHelper(testContext);
            var testRecord = new TestRecord
            {
                Id = 1,
                Name = "Anything"
            };
            dbOperationHelper.CreateTestRecord(testRecord);

            testContext.HasBeenSaved<TestRecord>(x => x.Id == 1 && x.Name == "Anything");
        }
        public void Can_remove_existing_entity()
        {
            var testRecord = new TestRecord
            {
                Id = 1,
                Name = "Anything"
            };
            var testContext = new ConfigurableContext<TestDbContext>(ctx =>
            {
                ctx.Setup(x => x.TestRecords, testRecord);
            });

            var dbOperationHelper = new DbOperationsHelper(testContext);

            dbOperationHelper.RemoveTestRecord(1);

            testContext.HasNotBeenSaved<TestRecord>(x => x.Id == 1);
        }
        public void Can_verify_updated_entity_has_been_saved_with_modified_properties()
        {
            var testRecord = new TestRecord
            {
                Id = 1,
                Name = "Anything"
            };
            var testContext = new ConfigurableContext<TestDbContext>(ctx =>
            {
                ctx.Setup(x => x.TestRecords, testRecord);
            });

            var dbOperationHelper = new DbOperationsHelper(testContext);

            dbOperationHelper.UpdateTestRecordName(1, "Joe");

            testContext.HasBeenSaved<TestRecord>(x => x.Name == "Joe");
        }