public async Task GetKundeByIdWithIllegalIdTest()
        {
            // arrange
            KundeRequest toGet = new KundeRequest {
                Id = -1
            };

            // assert
            Assert.Throws <RpcException>(() => _target.Get(toGet));
        }
Example #2
0
        public override async Task <KundeDto> Get(KundeRequest request, ServerCallContext context)
        {
            KundeManager manager  = new KundeManager();
            Kunde        customer = await manager.Get(request.Id);

            if (customer == null)
            {
                throw new RpcException(new Status(
                                           StatusCode.OutOfRange, "Id couldn't be found."
                                           ));
            }
            return(customer.ConvertToDto());
        }
        public override async Task <KundeDto> Get(KundeRequest request, ServerCallContext context)
        {
            Kunde result = await ClientManager.Get(request.Id);

            if (result == null)
            {
                throw new RpcException(new Status(
                                           StatusCode.OutOfRange,
                                           "Client not found"
                                           ));
            }
            return(result.ConvertToDto());
        }
        public async Task DeleteKundeTest()
        {
            // arrange
            KundeRequest toDelete = new KundeRequest {
                Id = 1
            };
            KundeDto kunde = _target.Get(toDelete);

            // act
            _target.Delete(kunde);

            // assert
            Assert.Throws <RpcException>(() => _target.Get(toDelete));
        }
        public async Task UpdateKundeWithOptimisticConcurrencyTest()
        {
            // arrange
            KundeRequest toUpdate = new KundeRequest {
                Id = 1
            };
            KundeDto kunde           = _target.Get(toUpdate);
            KundeDto concurrentKunde = _target.Get(toUpdate);

            // act
            _target.Update(concurrentKunde);

            // assert
            Assert.Throws <RpcException>(() => _target.Update(kunde));
        }
        public async Task UpdateKundeTest()
        {
            // arrange
            string       newNachname = "asdf";
            KundeRequest toUpdate    = new KundeRequest {
                Id = 1
            };
            KundeDto kunde = _target.Get(toUpdate);

            // act
            kunde.Nachname = newNachname;
            _target.Update(kunde);

            // assert
            Assert.Equal(newNachname, _target.Get(toUpdate).Nachname);
        }