public async Task When_RemovingItemFromBucket_Expect_Removed() { // Arrange Bucket bucket = new Bucket(); Item item = new Item(); bucket.AddItem(item); await this.repository.AddAsync(bucket); RemoveItem.Command command = new RemoveItem.Command( bucketId: bucket.Id, itemId: item.Id); RemoveItem.Handler handler = new RemoveItem.Handler(this.repository); // Act await handler.Handle(command, default); // Assert Assert.DoesNotContain(item, this.repository.Get(bucket.Id)?.Items); }
public async Task When_RemovingItemFromNonExistingBucket_Expect_BucketNotFoundException() { // Arrange Bucket bucket = new Bucket(); Item item = new Item(); bucket.AddItem(item); await this.repository.AddAsync(bucket); RemoveItem.Command command = new RemoveItem.Command( bucketId: new Random().Next(int.MaxValue), itemId: item.Id); RemoveItem.Handler handler = new RemoveItem.Handler(this.repository); // Act Exception exception = await Record.ExceptionAsync(() => handler.Handle(command, default)); // Assert Assert.IsType <BucketNotFoundException>(exception); Assert.NotEmpty(this.repository.Get(bucket.Id)?.Items); }