コード例 #1
0
        public void GetListTestForAll()
        {
            var rawClientMock = new Mock <IMilkRawClient>();

            rawClientMock
            .Setup(client => client.Invoke(It.IsAny <string>(), It.IsAny <IDictionary <string, string> >()))
            .Callback <string, IDictionary <string, string> >((method, parameters) =>
            {
                Assert.Equal("rtm.tasks.getList", method);
            })
            .Returns(() => Task.FromResult(@"
                    <rsp stat=""ok"">
                        <tasks>
                            <list id=""1"">
                                <taskseries id=""2"" created=""2015-05-07T10:19:54Z"" modified=""2015-05-07T10:19:54Z""
                                    name=""Get Bananas"" source=""api"" url=""http://example.com"" location_id="""">
                                    <tags/>
                                    <participants/>
                                    <notes/>
                                    <task id=""3"" due="""" has_due_time=""0"" added=""2015-05-07T10:19:54Z""
                                        completed="""" deleted="""" priority=""N"" postponed=""0"" estimate=""""/>
                                </taskseries>
                            </list>
                        </tasks>
                    </rsp>
                    "));
            var rawClient = rawClientMock.Object;

            var milkTasks = new MilkClient(rawClient).Tasks;

            IObservable <MilkTask> taskObservable = milkTasks.GetList();

            taskObservable.Subscribe(task =>
            {
                Assert.Equal(1, task.ListId);

                MilkTaskSeries taskSeries = task.TaskSeries;
                Assert.Equal(2, taskSeries.Id);

                Assert.Equal(3, task.Id);
            });
        }
コード例 #2
0
        public void GetListTestForAllList()
        {
            var rawClientMock = new Mock <IMilkRawClient>();

            rawClientMock
            .Setup(client => client.Invoke(It.IsAny <string>(), It.IsAny <IDictionary <string, string> >()))
            .Callback <string, IDictionary <string, string> >((method, parameters) =>
            {
                Assert.Equal("rtm.lists.getList", method);
            })
            .Returns(() => Task.FromResult(@"
                    <rsp stat=""ok"">
                        <lists>
                            <list id=""100653"" name=""Inbox""
                                deleted=""1"" locked=""1"" archived=""1"" position=""-1"" smart=""1"">
                                <filter>(priority:1)</filter>
                            </list>
                        </lists>
                    </rsp>
                    "));
            var rawClient = rawClientMock.Object;

            var lists = new MilkClient(rawClient).Lists;

            IObservable <MilkList> listObservable = lists.GetList();

            listObservable.Subscribe(
                list =>
            {
                Assert.Equal(100653, list.Id);
                Assert.Equal("Inbox", list.Name);
                Assert.True(list.Deleted);
                Assert.True(list.Locked);
                Assert.True(list.Archived);
                Assert.Equal(-1, list.Position);
                Assert.True(list.Smart);
                Assert.Equal("(priority:1)", list.Filter);
            });
        }