Exemplo n.º 1
0
            public void PrependsTheNewTagToTheTagList()
            {
                var  tagName     = "Some Tag";
                long workspaceId = 123;
                var  initialTags = CreateTags(count: 10);

                InteractorFactory
                .GetTagsAutocompleteSuggestions(Arg.Any <IList <string> >())
                .Execute()
                .Returns(Observable.Return(initialTags));
                var createdTag = CreateTagSubstitute(0, tagName);

                createdTag.WorkspaceId.Returns(workspaceId);
                InteractorFactory.CreateTag(Arg.Is(tagName), Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(createdTag));
                ViewModel.Prepare((new long[0], workspaceId));
                ViewModel.Initialize().Wait();
                //Reconfigure AutocopleteProvider, so it returns the created tag as well
                var createdTagSuggestion = new TagSuggestion(createdTag);
                var newTagSuggestions    = initialTags
                                           .Concat(new AutocompleteSuggestion[] { createdTagSuggestion });
                var observable = Observable
                                 .Return(newTagSuggestions);

                InteractorFactory
                .GetTagsAutocompleteSuggestions(Arg.Any <IList <string> >())
                .Execute()
                .Returns(observable);
                ViewModel.Text = tagName;

                ViewModel.CreateTagCommand.ExecuteAsync(tagName).Wait();

                ViewModel.Tags.First().Name.Should().Be(tagName);
            }
Exemplo n.º 2
0
            public async Task TrimsTheTagName(string text, string expectedName)
            {
                await prepare(12, 13);

                ViewModel.Text = text;

                await ViewModel.CreateTagCommand.ExecuteAsync(text);

                await InteractorFactory
                .CreateTag(Arg.Is(expectedName), Arg.Any <long>())
                .Received()
                .Execute();
            }
Exemplo n.º 3
0
            public void CreatesNewTagWithWorkspaceOfViewModel(long workspaceId)
            {
                prepare(240, workspaceId).Wait();
                var tagName = "some tag";

                ViewModel.Text = tagName;

                ViewModel.CreateTagCommand.ExecuteAsync(tagName).Wait();

                InteractorFactory
                .CreateTag(Arg.Any <string>(), Arg.Is(workspaceId))
                .Received()
                .Execute()
                .Wait();
            }
Exemplo n.º 4
0
            public void CreatesNewTagWithProvidedName(NonEmptyString nonEmptyString)
            {
                var name = nonEmptyString.Get.Trim();

                prepare(420, 10).Wait();
                ViewModel.Text = name;

                ViewModel.CreateTagCommand.ExecuteAsync(name).Wait();

                InteractorFactory
                .CreateTag(Arg.Is(name), Arg.Any <long>())
                .Received()
                .Execute()
                .Wait();
            }
Exemplo n.º 5
0
            public async Task ReturnsFalseIfTagIsCreated()
            {
                DataSource.Tags.GetAll().Returns(Observable.Return(new List <IThreadSafeTag>()));

                var newTag = Substitute.For <IThreadSafeTag>();

                newTag.Id.Returns(12345);

                InteractorFactory
                .CreateTag(Arg.Any <string>(), Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(newTag));

                ViewModel.Prepare((new long[] { }, workspaceId));
                await ViewModel.Initialize();

                ViewModel.CreateTagCommand.Execute("some-tag");

                ViewModel.IsEmpty.Should().BeFalse();
            }
Exemplo n.º 6
0
            private async Task prepare(long tagId, long workspaceId)
            {
                ViewModel.Prepare((new long[0], workspaceId));
                await ViewModel.Initialize();

                var createdTag = Substitute.For <IThreadSafeTag>();

                createdTag.Id.Returns(tagId);
                createdTag.WorkspaceId.Returns(workspaceId);
                InteractorFactory
                .CreateTag(Arg.Any <string>(), Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(createdTag));

                var observable = Observable
                                 .Return(new AutocompleteSuggestion[] { new TagSuggestion(createdTag) });

                InteractorFactory
                .GetTagsAutocompleteSuggestions(Arg.Any <IList <string> >())
                .Execute()
                .Returns(observable);
            }