Ejemplo n.º 1
0
        public async Task GetCarHelpEntries_Invoke()
        {
            var carHelpEntry = new CarHelpEntry
            {
                Id = Guid.NewGuid()
            };

            var carHelpEntry2 = new CarHelpEntry
            {
                Id = Guid.NewGuid()
            };

            var carHelpEntries = new List <CarHelpEntry> {
                carHelpEntry, carHelpEntry2
            }.AsQueryable();

            var mockCarSet = FakeDbSetFactory <CarHelpEntry> .Get(carHelpEntries);

            _fakeDb.Setup(m => m.GetSet <CarHelpEntry>()).Returns(mockCarSet.Object);
            _sut = new CarHelpEntryService(_fakeDb.Object);

            var result = await _sut.GetCarHelpEntries();

            result.TotalCount.Should().Be(2);
        }
Ejemplo n.º 2
0
        public async Task UpdateCarHelpEntry_Invoke()
        {
            var carHelpEntry = new CarHelpEntry
            {
                Id = Guid.NewGuid()
            };

            var dto = new UpdateCarHelpEntryRequestDto
            {
                CarHelpId   = carHelpEntry.Id.ToString(),
                Description = "test"
            };


            var carHelpEntries = new List <CarHelpEntry> {
                carHelpEntry
            }.AsQueryable();

            var mockCarSet = FakeDbSetFactory <CarHelpEntry> .Get(carHelpEntries);

            _fakeDb.Setup(m => m.GetSet <CarHelpEntry>()).Returns(mockCarSet.Object);
            _sut = new CarHelpEntryService(_fakeDb.Object);

            await _sut.UpdateCarHelpEntry(dto);

            _fakeDb.Verify(v => v.GetSet <CarHelpEntry>());
            _fakeDb.Verify(v => v.SaveDbAsync());

            carHelpEntry.Description.Should().Be(dto.Description);
        }
Ejemplo n.º 3
0
        public async Task CreateCarHelpEntry(CreateCarHelpEntryRequestDto request)
        {
            var model = new CarHelpEntry
            {
                Name        = request.Name,
                CarId       = new Guid(request.CarId),
                Employee    = request.Employee,
                Created     = DateTime.UtcNow,
                Description = request.Description,
                Price       = request.Price,
                Status      = request.Status
            };

            await _dataService.GetSet <CarHelpEntry>().AddAsync(model);

            await _dataService.SaveDbAsync();
        }