public void Add_WhenAssetProvided_ShouldCallDbContextSetAssetProperty_Test() { Setup_Repository_MockDbContext(new List <Asset>()); // Arrange var newAsset = new Asset { /*Id = 1,*/ AssetTypeId = 2, Name = "b", IsActive = true }; // reset count for repository call _callCount = 0; // Act _repository.Add(newAsset); // Assert Assert.That(_callCount, Is.EqualTo(1)); }
public void Add_WhenAssetProvided_AddEntityToDbContext_Test() { // Arrange _fakeDbContext = new FinancialDbContext(); _repository = new AssetRepository(_fakeDbContext); var expectedAsset = new Asset { /*Id = 1,*/ AssetTypeId = 2, Name = "b", IsActive = true }; // Act _repository.Add(expectedAsset); var actualAsset = _fakeDbContext.Assets.Local.ToList()[0]; // Assert Assert.Multiple(() => { Assert.That(actualAsset.Id, Is.EqualTo(0), "Asset Id"); Assert.That(actualAsset.Name, Is.EqualTo(expectedAsset.Name), "Asset Name"); Assert.That(actualAsset.AssetTypeId, Is.EqualTo(expectedAsset.AssetTypeId), "AssetType Id"); Assert.That(actualAsset.IsActive, Is.EqualTo(expectedAsset.IsActive), "IsActive"); }); }
public void CreateAsset(params Asset[] Assets) { /* Validation and error handling omitted */ _assetRepository.Add(Assets); }