public async Task When_UpdatingBucket_Expect_UpdatedBucked() { // Arrange Bucket bucket = new Bucket { Name = Guid.NewGuid().ToString(), Description = Guid.NewGuid().ToString(), Size = new Random().Next(int.MaxValue), }; await this.repository.AddAsync(bucket); UpdateBucket.Command command = new UpdateBucket.Command( id: bucket.Id, name: Guid.NewGuid().ToString(), description: Guid.NewGuid().ToString(), size: new Random().Next(int.MaxValue)); UpdateBucket.Handler handler = new UpdateBucket.Handler(this.repository); // Act UpdateBucket.Response response = await handler.Handle(command, default); // Assert Assert.False(response.Created); Assert.True(response.Updated); Assert.Equal(bucket.Id, response.Bucket.Id); Assert.Equal(bucket.Name, response.Bucket.Name); Assert.Equal(bucket.Description, response.Bucket.Description); Assert.Equal(bucket.Size, response.Bucket.Size); }
public async Task When_UpdatingNonExistingBucketResultingInDomainConflict_Expect_DomainException() { // Arrange UpdateBucket.Command command = new UpdateBucket.Command( id: new Random().Next(int.MaxValue), name: Guid.NewGuid().ToString(), description: null, size: -1); UpdateBucket.Handler handler = new UpdateBucket.Handler(this.repository); // Act Exception exception = await Record.ExceptionAsync(() => handler.Handle(command, default)); // Assert Assert.IsAssignableFrom <DomainException>(exception); }
public async Task When_UpdatingBucketResultingInDomainConflict_Expect_DomainException() { // Arrange Bucket bucket = new Bucket(); bucket.AddItem(new Item()); await this.repository.AddAsync(bucket); UpdateBucket.Command command = new UpdateBucket.Command( id: bucket.Id, name: Guid.NewGuid().ToString(), description: null, size: 0); UpdateBucket.Handler handler = new UpdateBucket.Handler(this.repository); // Act Exception exception = await Record.ExceptionAsync(() => handler.Handle(command, default)); // Assert Assert.IsAssignableFrom <DomainException>(exception); }