public void GetAll_ThreeItemsInCollection_ShouldReturnAllThree()
        {
            _mongoDatabaseUtilities.AddItem(_testSiteOne);
            _mongoDatabaseUtilities.AddItem(_testSiteTwo);
            _mongoDatabaseUtilities.AddItem(_testSiteThree);

            var resultFromDatabase = _sourceRepository.GetAll();

            Assert.AreEqual(3, resultFromDatabase.Count);

            SiteAssertor.New()
            .Expected(_testSiteOne)
            .Actual(resultFromDatabase.Find(a => a.Id == _testSiteOne.Id))
            .DoAssert();

            SiteAssertor.New()
            .Expected(_testSiteTwo)
            .Actual(resultFromDatabase.Find(a => a.Id == _testSiteTwo.Id))
            .DoAssert();

            SiteAssertor.New()
            .Expected(_testSiteThree)
            .Actual(resultFromDatabase.Find(a => a.Id == _testSiteThree.Id))
            .DoAssert();
        }
        public void UpdateById_InvalidObjectId_ShouldReturnFalseAndNotUpdate()
        {
            // Setup
            _mongoDatabaseUtilities.AddItem(_testSiteOne);

            var updatedDetails = new Source
            {
                Name    = "Altered Name One",
                BaseUrl = "https://www.changedurlone.com"
            };

            // Perform
            var invalidObjectId = "5c72a6f52f44614ba8c56071";
            var result          = _sourceRepository.UpdateById(invalidObjectId, _testSiteOne);

            // Verify
            Assert.IsFalse(result);

            var recordFromDatabase = _mongoDatabaseUtilities.FindRecordById(_testSiteOne.Id);

            SiteAssertor.New()
            .Expected(_testSiteOne)
            .Actual(recordFromDatabase[0])
            .DoAssert();
        }
        public void Add_SingleValidSource_ShouldBeInserted()
        {
            _mongoDatabaseUtilities.AddItem(_testSiteOne);

            var retrievedSource = _mongoDatabaseUtilities.FindRecordById(_testSiteOne.Id);

            SiteAssertor.New()
            .Expected(_testSiteOne)
            .Actual(retrievedSource[0])
            .DoAssert();
        }
        public void GetById_ValidObjectId_ShouldReturnSingleSource()
        {
            _mongoDatabaseUtilities.AddItem(_testSiteOne);
            // This has same details, but different Id to the above
            _mongoDatabaseUtilities.AddItem(TestSourceOne());

            var result = _sourceRepository.GetById(_testSiteOne.Id);

            SiteAssertor.New()
            .Expected(_testSiteOne)
            .Actual(result)
            .DoAssert();
        }
        public void GetByName_ValidName_ShouldReturnSingleSource()
        {
            _mongoDatabaseUtilities.AddItem(_testSiteOne);
            // This has same details, but different Id to the above
            _mongoDatabaseUtilities.AddItem(_testSiteTwo);

            var result = _sourceRepository.GetByName(_testSiteOne.Name);

            Assert.AreEqual(1, result.Count);
            SiteAssertor.New()
            .Expected(_testSiteOne)
            .Actual(result[0])
            .DoAssert();
        }
        public void UpdateById_ValidObjectId_ShouldUpdateAndReturnTrue()
        {
            _mongoDatabaseUtilities.AddItem(_testSiteOne);
            _mongoDatabaseUtilities.AddItem(_testSiteTwo);

            _testSiteOne.Name    = "Altered Name One";
            _testSiteOne.BaseUrl = "https://www.changedurlone.com";

            var result = _sourceRepository.UpdateById(_testSiteOne.Id, _testSiteOne);

            Assert.IsTrue(result);

            var recordFromDatabase = _mongoDatabaseUtilities.FindRecordById(_testSiteOne.Id);

            SiteAssertor.New()
            .Expected(_testSiteOne)
            .Actual(recordFromDatabase[0])
            .DoAssert();
        }