public virtual void Patch(AssociationEntity target) { target.Priority = Priority; target.Tags = Tags; target.AssociationType = AssociationType; target.Quantity = Quantity; }
public virtual void Patch(AssociationEntity target) { target.Priority = Priority; target.Tags = Tags; target.AssociationType = AssociationType; target.Quantity = Quantity; target.ItemId = ItemId; target.AssociatedItemId = AssociatedItemId; target.AssociatedCategoryId = AssociatedCategoryId; }
public async Task UpdateAssociationsAsync_AddNewAssociation_Added(dataModel.AssociationEntity entity) { // Arrange var associationServiceMock = CreateProductAssociationServiceMock(new[] { entity }); var productAssociation = new ProductAssociation() { Id = null, ItemId = entity.ItemId, AssociatedObjectId = "NEW_AssociatedItemId", AssociatedObjectType = entity.AssociationType, Type = entity.AssociationType, Priority = 10 }; // Act await associationServiceMock.UpdateAssociationsAsync(new[] { productAssociation }); // Assert _catalogRepositoryMock.Verify(x => x.Add(It.Is <dataModel.AssociationEntity>(q => q.AssociatedItemId == "NEW_AssociatedItemId")), Times.Once); }
public async Task UpdateAssociationsAsync_UpdateAssociation_Changed(dataModel.AssociationEntity entity) { // Arrange var associationServiceMock = CreateProductAssociationServiceMock(new[] { entity }); var productAssociation = new ProductAssociation() { Id = entity.Id, ItemId = "new_Item_ID", AssociatedObjectId = "new_object_Id", AssociatedObjectType = entity.AssociationType, }; // Act await associationServiceMock.UpdateAssociationsAsync(new[] { productAssociation }); // Assert Assert.Equal(productAssociation.ItemId, entity.ItemId); _catalogRepositoryMock.Verify(x => x.Add(It.IsAny <dataModel.AssociationEntity>()), Times.Never); }
public async Task UpdateAssociationsAsync_UpdateTransientAssociation_Changed(dataModel.AssociationEntity entity) { // Arrange var associationServiceMock = CreateProductAssociationServiceMock(new[] { entity }); var productAssociation = new ProductAssociation { Id = null, ItemId = entity.ItemId, AssociatedObjectId = entity.AssociatedItemId, AssociatedObjectType = entity.AssociationType, Type = entity.AssociationType, Priority = 10 }; // Act await associationServiceMock.UpdateAssociationsAsync(new[] { productAssociation }); // Assert Assert.Equal(productAssociation.Priority, entity.Priority); _catalogRepositoryMock.Verify(x => x.Add(It.IsAny <dataModel.AssociationEntity>()), Times.Never); }
public void Compare_NotEqualAssociation_NotEqual(dataModel.AssociationEntity x, dataModel.AssociationEntity y) { var result = new dataModel.AssociationEntityComparer().Equals(x, y); Assert.False(result); }
public async Task SaveChangesAsync_UpdateExistingTransientAssociation_Changed(dataModel.AssociationEntity association) { var associationServiceMock = CreateProductAssociationServiceMock(new List <dataModel.AssociationEntity>() { association }); var product = new CatalogProduct() { Id = "originalItemId", Name = "Owner object", Associations = new List <ProductAssociation>() { new ProductAssociation() { Id = null, ItemId = "originalItemId", AssociatedObjectId = association.AssociatedItemId, AssociatedObjectType = association.AssociationType, Type = association.AssociationType, Priority = 66 } } }; // Act await associationServiceMock.SaveChangesAsync(new IHasAssociations[] { product }); // Assert Assert.Equal(association.Priority, product.Associations.First().Priority); _catalogRepositoryMock.Verify(x => x.Add(It.IsAny <dataModel.AssociationEntity>()), Times.Never); }
public async Task SaveChangesAsync_SetEmptyAssociationCollections_ExistingDeleted(dataModel.AssociationEntity association) { // Arrange var associationServiceMock = CreateProductAssociationServiceMock(new List <dataModel.AssociationEntity>() { association }); var product = new CatalogProduct() { Id = "originalItemId", Name = "Owner object", Associations = new List <ProductAssociation>() { } }; // Act await associationServiceMock.SaveChangesAsync(new IHasAssociations[] { product }); // Assert _catalogRepositoryMock.Verify(x => x.Remove(It.Is <dataModel.AssociationEntity>(q => q.Id == "originalId")), Times.Once); }