public async Task CreateAsync_Should_Create_Successfully()
        {
            //Arrange
            var context = Context;

            IOfficeBusiness officeBusiness = new OfficeBusiness(context,
                                                                _mapper,
                                                                _cache,
                                                                _busMock.Object);

            CreateOfficeCommand command = new CreateOfficeCommand
            {
                Location  = "Amsterdam",
                OpenTime  = DateTime.Now.TimeOfDay,
                CloseTime = DateTime.Now.AddHours(1).TimeOfDay
            };

            //Act
            await officeBusiness.CreateAsync(command);

            var addedOffice = await context.Offices
                              .FirstOrDefaultAsync();

            //Assert
            Assert.NotNull(addedOffice);

            Assert.Equal("Amsterdam", addedOffice.Location);
        }
        public async Task CreateAsync_Should_Publish_Event_Successfully()
        {
            //Arrange
            var context = Context;

            var harness = new InMemoryTestHarness();

            await harness.Start();

            IOfficeBusiness officeBusiness = new OfficeBusiness(context,
                                                                _mapper,
                                                                _cache,
                                                                harness.Bus);

            CreateOfficeCommand command = new CreateOfficeCommand
            {
                Location  = "Amsterdam",
                OpenTime  = DateTime.Now.TimeOfDay,
                CloseTime = DateTime.Now.AddHours(1).TimeOfDay
            };

            //Act
            await officeBusiness.CreateAsync(command);

            //Assert
            try
            {
                Assert.True(await harness.Published.Any <OfficeCreated>());
            }
            finally
            {
                await harness.Stop();
            }
        }
        public async Task CreateAsync_Should_Throw_Exception_IfModelNull()
        {
            //Arrange
            IOfficeBusiness officeBusiness = new OfficeBusiness(Context,
                                                                _mapper,
                                                                _cache,
                                                                _busMock.Object);

            async Task func() => await officeBusiness.CreateAsync(null);

            //Act & Assert
            await Assert.ThrowsAsync <ArgumentNullException>(func);
        }