Пример #1
0
        public async Task expected_domain_event_is_raised_when_creating_a_capability()
        {
            var capability = await _capabilityFactory.Create("Foo", "bar");

            Assert.Equal(
                expected: new[] { new CapabilityCreated(capability.Id, "Foo") },
                actual: capability.DomainEvents,
                comparer: new PropertiesComparer <IDomainEvent>()
                );
        }
Пример #2
0
        public async Task <Capability> CreateCapability(string name, string description)
        {
            var capability = await _capabilityFactory.Create(name, description);

            await _capabilityRepository.Add(capability);

            return(capability);
        }
Пример #3
0
        public async ValueTask <Capability> Create(string name, string description)
        {
            var existingCapabilities = await _capabilityRepository.GetAll();

            var capabilitiesWithSameName = existingCapabilities.Where(c => c.Name == name);

            if (capabilitiesWithSameName.Any())
            {
                throw  new CapabilityWithSameNameExistException(name);
            }

            return(await _inner.Create(name, description));
        }