Esempio n. 1
0
 public void AssignStartMap(Voteable v)
 {
     if (v.GetComponent <MapButton> () != null)
     {
         gui.mapSelect.SetCurrentMap(v.GetVotableID());
     }
 }
Esempio n. 2
0
        public void Question_CanBeCreated_Successfully()
        {
            // Arrange
            var    user        = new UserBuilder().BuildValidUser().Build();
            int    tagCount    = 3;
            string title       = "TitleNormal";
            string body        = "BodyNormal";
            var    tags        = new TagBuilder().Build(tagCount);
            var    limits      = new LimitsBuilder().Build();
            var    voteable    = new Voteable();
            var    commentable = new Commentable();

            // Act
            var result = Question.Create(user, title, body, tags, limits);

            // Assert
            Assert.NotEqual(default(Guid), result.Id);
            Assert.Equal(user, result.User);
            Assert.Equal(title, result.Title);
            Assert.Equal(body, result.Body);
            Assert.False(result.HasAcceptedAnswer);
            Assert.True(DateTime.UtcNow - result.CreatedOn < TimeSpan.FromSeconds(1));
            Assert.Empty(result.Answers);
            Assert.Empty(result.Comments);
            Assert.Equal(3, result.QuestionTags.Count());
        }
Esempio n. 3
0
    //functions to bind MapSelect button decision callbacks to.
    //they have to be here because they need to reference a MonoBehavior.

    //sends a start game message to all clients. All clients that recieve this will then request a unit sync from the server.
    public void SendStartGame(Voteable v)
    {
        Debug.Log("Start game called.");
        if (state.isServer)
        {
            state.StartGame();
            state.network.SendMessage(new StartGame());
        }
    }
Esempio n. 4
0
        public CommentBuilder SetupValidComment(int orderNumber = 1)
        {
            var    user     = new UserBuilder().BuildUser(new Guid("00000000-0000-0000-0000-000000000002")).Build();
            string body     = "BodyNormal";
            var    voteable = new Voteable();

            _target = Comment.Create(user, body, orderNumber, _limits);
            return(this);
        }
Esempio n. 5
0
        public void Comment_CreatingWithInvalidData_FailsValidation(string userId, int orderNumber, string body)
        {
            // Arrange
            var limits   = new LimitsBuilder().Build();
            var voteable = new Voteable();
            var user     = new UserBuilder().BuildUser(new Guid(userId)).Build();

            // Act, Assert
            Assert.Throws <BusinessException>(() => Comment.Create(user, body, orderNumber, limits));
        }
Esempio n. 6
0
        public void Question_CreatingWithInvalidData_FailsValidation(string userId, int tagCount, string title, string body)
        {
            // Arrange
            var user        = new UserBuilder().BuildUser(new Guid(userId)).Build();
            var tags        = new TagBuilder().Build(tagCount);
            var limits      = new LimitsBuilder().Build();
            var voteable    = new Voteable();
            var commentable = new Commentable();

            // Act, Assert
            Assert.Throws <BusinessException>(() =>
                                              Question.Create(user, title, body, tags, limits));
        }
Esempio n. 7
0
        public QuestionBuilder SetupValidQuestion()
        {
            var    user        = new UserBuilder().BuildValidUser().Build();
            int    tagCount    = 3;
            string title       = "TitleNormal";
            string body        = "BodyNormal";
            var    tags        = new TagBuilder().Build(tagCount);
            var    voteable    = new Voteable();
            var    commentable = new Commentable();

            _target = Question.Create(user, title, body, tags, _limits);
            return(this);
        }
Esempio n. 8
0
        public void Answer_CreatingWithInvalidData_FailsValidation(string userId, string body)
        {
            // Arrange
            var question    = new QuestionBuilder().SetupValidQuestion().Build();
            var limits      = new LimitsBuilder().Build();
            var voteable    = new Voteable();
            var commentable = new Commentable();
            var user        = new UserBuilder().BuildUser(new Guid(userId)).Build();

            // Act, Assert
            Assert.Throws <BusinessException>(() =>
                                              Answer.Create(user, body, question, limits));
        }
Esempio n. 9
0
    public MapData GetMapData()
    {
        Voteable v = voteables[mapState.currentMapID];

        Debug.Log("current map voteable ID: " + mapState.currentMapID);
        MapButton button = v.GetComponent <MapButton> ();

        Debug.Log("Button being referenced: " + button);
        MapData data = button.GetMap();

        Debug.Log("MapData of referenced button: " + data);

        return(voteables[mapState.currentMapID].GetComponent <MapButton> ().GetMap());
    }
Esempio n. 10
0
        public void Comment_CanGetCreatedWithValidData_Successfully()
        {
            // Arrange
            var user        = new UserBuilder().BuildValidUser().Build();
            var body        = "BodyNormal";
            var orderNumber = 1;
            var limits      = new LimitsBuilder().Build();
            var voteable    = new Voteable();

            // Act
            var result = Comment.Create(user, body, orderNumber, limits);

            // Assert
            Assert.Equal(user, result.User);
            Assert.Equal(body, result.Body);
            Assert.Equal(orderNumber, result.OrderNumber);
        }
Esempio n. 11
0
        public void Question_CreatingWithWrongNumberOfTags_Fails(int tagCount)
        {
            // Arrange
            var user  = new UserBuilder().BuildValidUser().Build();
            var title = "TitleNormal";
            var body  = "BodyNormal";
            var tags  = Builder <Tag>
                        .CreateListOfSize(tagCount)
                        .Build()
                        .ToList();

            var limits      = new LimitsBuilder().Build();
            var voteable    = new Voteable();
            var commentable = new Commentable();

            // Act, Assert
            Assert.Throws <BusinessException>(() =>
                                              Question.Create(user, title, body, tags, limits));
        }
Esempio n. 12
0
    public void init(MapData map, Image mapPreview)
    {
        this.map        = map;
        this.mapPreview = mapPreview;

        Image i = GetComponent <Image> ();

        i.sprite = map.mapIcon;

        RectTransform rTrans = GetComponent <RectTransform> ();

        rTrans.sizeDelta = new Vector2(i.sprite.rect.width / 4, i.sprite.rect.height / 4);

        this.transform.GetChild(1).GetComponent <Text> ().text = map.name;
        this.transform.GetChild(0).GetComponent <ShowMapPreview> ().init(map, map.mapIcon, mapPreview, this.transform);
        Voteable v = GetComponent <Voteable> ();

        v.decisionCallback.AddListener(StateManager.state.AssignStartMap);
    }
Esempio n. 13
0
        public void Answer_CanBeCreated_Successfully()
        {
            // Arrange
            var    question    = new QuestionBuilder().SetupValidQuestion().Build();
            var    user        = new UserBuilder().BuildValidUser().Build();
            string body        = "BodyNormal";
            var    limits      = new LimitsBuilder().Build();
            var    voteable    = new Voteable();
            var    commentable = new Commentable();

            // Act
            var result = Answer.Create(user, body, question, limits);

            // Assert
            Assert.NotEqual(default(Guid), result.Id);
            Assert.Equal(user, result.User);
            Assert.Equal(body, result.Body);
            Assert.False(result.IsAcceptedAnswer);
            Assert.Null(result.AcceptedOn);
            Assert.True(DateTime.UtcNow - result.CreatedOn < TimeSpan.FromSeconds(1));
            Assert.Empty(result.Comments);
        }