public async Task ThenAccountIsAddedIfNew(
            AccountsRepository sut,
            AccountEntity newEntity)
        {
            var expectedCountAfterAdd = (await sut.GetList()).Count + 1;

            // Act
            await sut.AddOrUpdate(newEntity);

            // Assert
            var actualCountAfterAdd = (await sut.GetList()).Count;

            actualCountAfterAdd.Should().Be(expectedCountAfterAdd);
        }
        public async Task ThenAccountIsUpdatedIfExisting(
            AccountsRepository sut,
            AccountEntity newEntity)
        {
            // Arrange
            await sut.AddOrUpdate(newEntity);

            var expectedCountAfterUpdate = (await sut.GetList()).Count;

            // Act
            await sut.AddOrUpdate(newEntity);

            // Assert
            var actualCountAfterAdd = (await sut.GetList()).Count;

            actualCountAfterAdd.Should().Be(expectedCountAfterUpdate);
        }
Esempio n. 3
0
        public async Task ThenAnEmptyListIsReturnedWhenSettingsFileDoesNotExist(
            AccountsRepository sut,
            IWorkingCopy workingCopy,
            Wrapper <string> inexistingSettingPath)
        {
            //Arrange
            Mock.Get(workingCopy).Setup(w => w.SettingsPath).Returns(inexistingSettingPath);

            //Act
            var accounts = await sut.GetList();

            // Assert
            accounts.Should().BeEmpty();
        }
Esempio n. 4
0
        public async Task ThenAnEmptyListIsReturnedWhenReadingTheFileFails(
            AccountsRepository sut,
            IWorkingCopy workingCopy,
            IMockFileDataAccessor mockFileDataAccessor,
            Wrapper <string> existingSettingPath)
        {
            //Arrange
            mockFileDataAccessor.AddFile(existingSettingPath, new MockFileData("{ invalid json }"));
            Mock.Get(workingCopy).Setup(w => w.SettingsPath).Returns(existingSettingPath);

            //Act
            var accounts = await sut.GetList();

            // Assert
            accounts.Should().BeEmpty();
        }
Esempio n. 5
0
        public async Task ThenStoredAccountsAreReturned(
            AccountsRepository sut,
            IWorkingCopy workingCopy,
            IMockFileDataAccessor mockFileDataAccessor,
            Wrapper <string> existingSettingPath,
            List <AccountEntity> existingEntities)
        {
            //Arrange
            var rawEntities = JsonConvert.SerializeObject(existingEntities);

            mockFileDataAccessor.AddFile(existingSettingPath, new MockFileData(rawEntities));
            Mock.Get(workingCopy).Setup(w => w.SettingsPath).Returns(existingSettingPath);

            //Act
            var accounts = await sut.GetList();

            // Assert
            accounts.Count.Should().Be(existingEntities.Count);
        }