示例#1
0
        public async Task activity_service_should_succeed()
        {
            var category = "test";
            var activityRepositoryMock = new Mock <IActivityRepository>();
            var categoryRepositoryMock = new Mock <ICategoryRepository>();

            categoryRepositoryMock.Setup(x => x.GetAsync(category)).ReturnsAsync(new Category(category));
            var activityService = new ActivityService(activityRepositoryMock.Object, categoryRepositoryMock.Object);
            var id = Guid.NewGuid();
            await activityService.AddAsync(id, Guid.NewGuid(), category, "activity", "description", DateTime.UtcNow);

            categoryRepositoryMock.Verify(x => x.GetAsync(category), Times.Once);
            activityRepositoryMock.Verify(x => x.AddAsync(It.IsAny <Activity>()), Times.Once);
        }
示例#2
0
        public async Task Activity_sevice_addAsync_should_succeed(string category)
        {
            categoryRepositoryMock.Setup(x => x.FindAsync(It.IsAny <Expression <Func <Category, bool> > >()))
            .ReturnsAsync(new Category(category));

            var id       = Guid.NewGuid();
            var activity = new Activity(id: id, userId: Guid.NewGuid(), category,
                                        createdAt: DateTime.UtcNow, createdBy: "juan", description: "description", name: "activity");

            await activityService.AddAsync(activity);

            categoryRepositoryMock.Verify(x => x.FindAsync(It.IsAny <Expression <Func <Category, bool> > >()), Times.Once);
            activityRepositoryMock.Verify(x => x.InsertAsync(It.IsAny <Activity>()), Times.Once);
        }
示例#3
0
        public async Task ActivityService_AddMethod_ShouldSucced()
        {
            //arrange
            var category           = "Test1";
            var activityRepository = new Mock <IActivityRepository>();
            var categoryRepository = new Mock <ICategoryRepository>();

            categoryRepository.Setup(s => s.GetAsync(category)).ReturnsAsync(new Category(category));
            var id = Guid.NewGuid();
            var activityService = new ActivityService(activityRepository.Object, categoryRepository.Object);
            //act
            await activityService.AddAsync(id, Guid.NewGuid(), category, "name", "description",
                                           DateTime.Now);

            //assert
            categoryRepository.Verify(s => s.GetAsync(category), Times.Once);
            activityRepository.Verify(s => s.AddAsync(It.IsAny <Activity>()), Times.Once);
        }
示例#4
0
        public async Task acivivity_add_async_method_should_succeed()
        {
            //arrange
            var category = "work";
            var activityRepositoryMock = new Mock <IActivityRepository>();
            var categoryRepositoryMock = new Mock <ICategoryRepository>();

            categoryRepositoryMock.Setup(x => x.GetAsync(category))
            .ReturnsAsync(new Category(category));
            var activityService = new ActivityService(activityRepositoryMock.Object, categoryRepositoryMock.Object);
            var id = Guid.NewGuid();
            //Act
            await activityService.AddAsync(id, Guid.NewGuid(), category, "activity", "description", DateTime.UtcNow);

            //Assert
            categoryRepositoryMock.Verify(x => x.GetAsync(category), Times.AtLeastOnce);
            activityRepositoryMock.Verify(x => x.AddAsync(It.IsAny <Activity>()), Times.AtLeastOnce);
        }
示例#5
0
        public async Task ActivityService_AddAsync_ShouldSucceed()
        {
            //Arrange
            var category = "test";
            var activityRepositoryMock = new Mock <IActivityRepository>();
            var categoryRepositoryMock = new Mock <ICategoryRepository>();

            categoryRepositoryMock.Setup(x => x.GetAsync(category))
            .ReturnsAsync(new Domain.Models.Category(category));
            var activityService = new ActivityService(activityRepositoryMock.Object, categoryRepositoryMock.Object);

            //Act
            var id = Guid.NewGuid();
            await activityService.AddAsync(id, Guid.NewGuid(), category, "activity", "description", DateTime.UtcNow);

            //Assert
            categoryRepositoryMock.Verify(x => x.GetAsync(category), Times.Once);
            activityRepositoryMock.Verify(x => x.AddAsync(It.IsAny <Activity>()), Times.Once);
        }