コード例 #1
0
        public void GetAllShouldReturnEmptyList()
        {
            var sut = new InMemoryCompanyRepository();

            var list = sut.GetAll();

            Assert.Empty(list);
        }
コード例 #2
0
        public void DeleteAfterAddingShouldRemoveItem()
        {
            var     sut     = new InMemoryCompanyRepository();
            Company company = new Company()
            {
                CreatedDate = new DateTime(),
                FoundedDate = new DateTime(),
                Name        = "My Company"
            };

            sut.Add(company);
            sut.Delete(company.CompanyId);
            var list = sut.GetAll();

            Assert.Empty(list);
        }
コード例 #3
0
        public void AddShouldAddOneItem()
        {
            var     sut     = new InMemoryCompanyRepository();
            Company company = new Company()
            {
                CreatedDate = new DateTime(),
                FoundedDate = new DateTime(),
                Name        = "My Company"
            };

            sut.Add(company);
            var list = sut.GetAll();

            Assert.Single(list);
            Assert.Equal(company.Name, list.First().Name);
        }
コード例 #4
0
        public void UpdateShouldChangeItemInList()
        {
            var     sut     = new InMemoryCompanyRepository();
            Company company = new Company()
            {
                CreatedDate = new DateTime(),
                FoundedDate = new DateTime(),
                Name        = "My Company"
            };
            int id = sut.Add(company);

            Company anotherCompany = new Company()
            {
                CreatedDate = company.CreatedDate,
                FoundedDate = company.FoundedDate,
                Name        = "Not my company",
                CompanyId   = id
            };

            sut.Update(anotherCompany);
            var list = sut.GetAll();

            Assert.Equal("Not my company", list.First().Name);
        }