Пример #1
0
        void when_following_someone()
        {
            act = () => result = controller.Follow("@you");

            context["other users exists"] = () =>
            {
                before = () =>
                {
                    var you            = GivenUser("*****@*****.**", "@you");
                    var existingFriend = GivenUser("*****@*****.**", "@other");
                    GivenUserIsFollowing(controller.UserId(), existingFriend);
                };

                it["contains new friend"] = () => Friends().should_contain("@you");

                it["user is notified that friend has been followed"] = () =>
                                                                       (result.Data.Message as string).should_be("You are now following @you.");

                it["added flag is set to true"] = () =>
                                                  ((bool)result.Data.Added).should_be_true();

                context["subsequent add of the same user"] = () =>
                {
                    act = () => result = controller.Follow("@you");

                    it["disregards add"] = () =>
                    {
                        (result.Data.Message as string).should_be("You are already following @you.");

                        ((bool)result.Data.Added).should_be_false();
                    };
                };
            };

            context["user doesn't exist"] = () =>
            {
                it["doesn't add friends"] = () => Friends().should_be_empty();

                it["user is notified that handle doesn't exist"] = () =>
                                                                   (result.Data.Message as string).should_be("User with handle @you doesn't exist.");

                it["added flag is set to false"] = () =>
                                                   ((bool)result.Data.Added).should_be_false();
            };
        }