public void CreateAsyncCamerasReturnMoreThanZero()
        {
            // Act (Do test)
            using (var context = new DataContext(options))
            {
                var repository = new GenericRepository <Camera>(context);

                var camera1 = new Camera
                {
                    Name = "TestCamera1",
                    User = context.Users.FirstOrDefault(),
                    City = context.City.FirstOrDefault()
                };


                var camera2 = new Camera
                {
                    Name = "TestCamera2",
                    User = context.Users.FirstOrDefault(),
                    City = context.City.FirstOrDefault()
                };

                repository.CreateAsync(camera1);
                repository.CreateAsync(camera2);
            }

            // Assert (Check results).
            using (var context = new DataContext(options))
            {
                Assert.GreaterOrEqual(context.Cameras.Count(), 2);
            }
        }
        public async Task Create_DuplicatedCategory_ShouldThrowException()
        {
            // .Arrange
            Category category = new Category()
            {
                CategoryName = "DUPLICATED"
            };

            using (var context = GetLinnworksIntegrationContext())
            {
                await context.AddAsync(category);

                await context.SaveChangesAsync();
            }
            var duplicatedCatgory = new Category()
            {
                CategoryName = category.CategoryName
            };

            // .Assert
            using (var context = GetLinnworksIntegrationContext())
            {
                var sut = new GenericRepository <Category>(context);
                Assert.That(async() =>
                            // .Act
                            await sut.CreateAsync(duplicatedCatgory), Throws.Exception);
            }
        }
        public void FindCamerasByIdReturnNotNull()
        {
            // Act (Do test)
            using (var context = new DataContext(options))
            {
                var repository = new GenericRepository <Camera>(context);

                var camera1 = new Camera
                {
                    Name = "TestCamera1",
                    User = context.Users.FirstOrDefault(),
                    City = context.City.FirstOrDefault()
                };

                repository.CreateAsync(camera1);
            }

            // Assert (Check results).
            using (var context = new DataContext(options: options))
            {
                var repository = new GenericRepository <Camera>(context: context);
                var result     = repository.GetByIdAsync(1);

                Assert.AreEqual(expected: result.Result.Name, "TestCamera1", message: "No se encuentra el usuario.");
            }
        }
        public void TestMethodInsertCamera()
        {
            // Act (Do test)
            using (var context = new DataContext(options))
            {
                var repository = new GenericRepository <Camera>(context);

                var camera1 = new Camera {
                    Name = "TestCamera1"
                };
                repository.CreateAsync(camera1);

                var insertedCamera = repository.GetByIdAsync(camera1.Id).Result;

                Assert.AreEqual(insertedCamera.Name, camera1.Name);
            }
        }
        public async Task Create_Category_ShouldGenerateID()
        {
            // .Arrange
            Category category = new Category()
            {
                CategoryName = Guid.NewGuid().ToString()
            };

            // .Act
            using (var context = GetLinnworksIntegrationContext())
            {
                var sut = new GenericRepository <Category>(context);
                category = await sut.CreateAsync(category);
            }

            // .Assert
            Assert.NotNull(category.Id);
            Assert.AreNotEqual(new Guid().ToString(), category.Id);
        }
示例#6
0
        public async Task <OutputHandler> CreateResourceType(ResourceTypeDTO resourceType)
        {
            try
            {
                var resource = new ResourceType {
                    ResourceTypeName = resourceType.ResourceTypeName
                };
                await _resourcTypeRepository.CreateAsync(resource);

                await _resourcTypeRepository.SaveChangesAsync();

                return(new OutputHandler
                {
                    IsErrorOccured = false,
                    Message = "Resource Type Created Successfully"
                });
            }
            catch (Exception ex)
            {
                return(StandardMessages.getExceptionMessage(ex));
            }
        }
示例#7
0
        public async Task <OutputHandler> CreateResourceCategory(ResourceCategoryDTO sermonCategory)
        {
            try
            {
                var series = new ResourceCategory {
                    CategoryName = sermonCategory.CategoryName
                };
                await _sermonCategoryRepository.CreateAsync(series);

                await _sermonCategoryRepository.SaveChangesAsync();

                return(new OutputHandler
                {
                    IsErrorOccured = false,
                    Message = "Resource Series Created Successfully"
                });
            }
            catch (Exception ex)
            {
                return(StandardMessages.getExceptionMessage(ex));
            }
        }
示例#8
0
 public Task <Tenant> CreateAsync(Tenant tenant, CancellationToken cancellationToken)
 {
     return(GenericRepository.CreateAsync(tenant, cancellationToken));
 }
示例#9
0
 public Task <Session> CreateAsync(Session session)
 {
     return(GenericRepository.CreateAsync(session));
 }
示例#10
0
 public Task <OccupiedChair> CreateAsync(OccupiedChair occupiedChair)
 {
     return(GenericRepository.CreateAsync(occupiedChair));
 }
        public async Task CreateAsync([FromBody] Blog blog)
        {
            await _repository.CreateAsync(blog);

            await _repository.SaveChangesAsync();
        }
示例#12
0
 public Task <Movie> CreateAsync(Movie movie)
 {
     return(GenericRepository.CreateAsync(movie));
 }
示例#13
0
 public Task <User> CreateAsync(User user)
 {
     return(GenericRepository.CreateAsync(user));
 }
示例#14
0
 public Task <User> CreateAsync(User user, CancellationToken cancellationToken)
 {
     return(GenericRepository.CreateAsync(user, cancellationToken));
 }
示例#15
0
 public Task <Room> CreateAsync(Room room)
 {
     return(GenericRepository.CreateAsync(room));
 }
示例#16
0
        public async Task Create()
        {
            var ret = await rep.CreateAsync(new Category());

            Assert.NotEqual(Guid.Empty, ret.Id);
        }