Пример #1
0
        public void DeleteCompany_ShouldDeleteRecord_WhenExistingIdIsPassed()
        {
            // Arrange
            var context = this.GetDbContext();

            this.PopulateData(context);

            // Act
            var service    = new CompanyLogic(context, mapper);
            var oldCompany = context.Companies.Find(5);

            service.DeleteCompany(oldCompany.Id);

            var company = context.Companies.Find(5);

            // Assert
            Assert.NotNull(oldCompany);
            Assert.False(oldCompany.IsActive);
        }
Пример #2
0
        public void DeleteCompany_ShouldDeleteRecord_WhenNotExistingIdIsPassed()
        {
            // Arrange
            var context = this.GetDbContext();

            this.PopulateData(context);
            Exception exception = null;

            // Act
            var service    = new CompanyLogic(context, mapper);
            var oldCompany = context.Companies.Find(50);

            try
            {
                service.DeleteCompany(oldCompany.Id);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            // Assert
            Assert.NotNull(exception);
        }