Exemplo n.º 1
0
        public void SendsMessageWhenCouldNotGetReviewForTeam()
        {
            const int telegramChatId = 123123;

            _chats.Add(new ChatBuilder {
                TelegramChatId = telegramChatId
            }.Build());
            var todayDate            = DateTime.Today;
            var messageStringBuilder = new StringBuilder($"{todayDate:D}, review duties for: {Environment.NewLine}");

            messageStringBuilder.AppendLine($"{Team.Desktop} team - DesktopUserName");
            messageStringBuilder.AppendLine($"Could not get review duty for {Team.Mobile} team");
            var message = messageStringBuilder.ToString();
            var desktopDeveloper = new DeveloperBuilder {
                UserName = "******", Team = Team.Desktop
            }.Build();

            _reviewByDateProviderMock.Setup(provider => provider.GetReview(todayDate, Team.Desktop))
            .ReturnsAsync(new Review {
                DateTime = todayDate, Developer = desktopDeveloper
            });
            var service = CreateService();

            service.SendMessage(todayDate);

            _sendMessageServiceMock.Verify(s => s.TrySendMessageAsync(telegramChatId, message), Times.Once);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("---- Solution 2  -----");

            var builder = new DeveloperBuilder();

            builder.CreateDeveloper("Franco", "Morales");
            var dotnetSeniorFullstack = builder.GetDeveloper();

            dotnetSeniorFullstack.Print();
        }
Exemplo n.º 3
0
        public async void SavesChangesOnTryUpdateDeveloperAndSave()
        {
            var developer = new DeveloperBuilder {
                UserName = "******"
            }.Build();

            _developers.Add(developer);
            var repository = CreateRepository();

            await repository.TryUpdateDeveloperAndSaveAsync(developer);

            _appDbContextMock.Verify(context => context.SaveChanges(), Times.Once);
        }
Exemplo n.º 4
0
        public async void TriesUpdateEntity()
        {
            var developer = new DeveloperBuilder {
                UserName = "******"
            }.Build();

            _developers.Add(developer);
            var repository = CreateRepository();

            var result = await repository.TryUpdateDeveloperAndSaveAsync(developer);

            result.Should().BeTrue();
        }
Exemplo n.º 5
0
        public void ThrowsExceptionWhenCannotFindDeveloperByUserName()
        {
            var developer = new DeveloperBuilder {
                UserName = "******"
            }.Build();

            _developers.Add(developer);
            var repository = CreateRepository();

            Action getDeveloperByUserNameAction = () => repository.GetDeveloperByUserName("UnknownUserName");

            getDeveloperByUserNameAction.Should().Throw <InvalidOperationException>();
        }
Exemplo n.º 6
0
        public void GetsDeveloperByUserName()
        {
            var developer = new DeveloperBuilder {
                UserName = "******"
            }.Build();

            _developers.Add(developer);
            var repository = CreateRepository();

            var actualDeveloper = repository.GetDeveloperByUserName("UserName");

            actualDeveloper.Should().Be(developer);
        }
Exemplo n.º 7
0
        public void RemovesChatWhenCouldNotSendMessage()
        {
            const int telegramChatId = 123123;
            var       chat = new ChatBuilder {
                TelegramChatId = telegramChatId
            }.Build();

            _chats.Add(chat);
            var todayDate = DateTime.Today;

            _reviewByDateProviderMock.Setup(provider => provider.GetReview(todayDate, Team.Desktop))
            .ReturnsAsync(new Review {
                DateTime = todayDate, Developer = DeveloperBuilder.Any()
            });
            _sendMessageServiceMock.Setup(s => s.TrySendMessageAsync(telegramChatId, It.IsAny <string>()))
            .ReturnsAsync(false);
            var service = CreateService();

            service.SendMessage(todayDate);

            _chatRepositoryMock.Verify(repository => repository.TryRemoveChatAndSave(chat), Times.Once);
        }
Exemplo n.º 8
0
 public void Inicializa()
 {
     DeveloperEntityFramework = new DeveloperRepository(dbContext);
     builder     = new DeveloperBuilder();
     transaction = dbContext.Database.BeginTransaction();
 }