<commit_before>﻿using System;
using System.Collections.Generic;
using biz.dfch.CS.Osram.Lightify.Client.Model;
using biz.dfch.CS.Web.Utilities.Rest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Telerik.JustMock;

namespace biz.dfch.CS.Osram.Lightify.Client.Tests
{
    [TestClass]
    public class ClientGroupOperationTest
    {
        public Client Sut;
        public RestCallExecutor RestCallExecutor;

        [TestInitialize]
        public void TestInitialize()
        {

            Sut = new Client(TestConstants.OSRAM_LIGHTIFY_BASE_URI)
            {
                UserInformation = new UserInformation()
                {
                    UserId = TestConstants.USER_ID,
                    Username = TestConstants.USERNAME,
                    Password = <PASSWORD>,
                    SerialNumber = TestConstants.SERIAL_NUMBER,
                    SecurityToken = TestConstants.SECURITY_TOKEN
                }
            };

            RestCallExecutor = Mock.Create<RestCallExecutor>();
        }

        [TestMethod]
        public void TurnLightGroupOnSucceeds()
        {
            var groupId = 1L;
            var group = new Group
            {
                GroupId = groupId,
                Name = "group1"
            };
            var responseOperation = new OperationResponse
            {
                ReturnCode = 0
            };


            Mock.Arrange(() => RestCallExecutor.Invoke(HttpMethod.Get, Arg.AnyString, Arg.IsAny<Dictionary<string, string>>(), ""))
                .IgnoreInstance()
                .Returns(responseOperation.SerializeObject)
                .OccursOnce();

            var result = Sut.TurnLightGroupOn(group);

            Mock.Assert(RestCallExecutor);
            Assert.IsNotNull(result);
            Assert.AreEqual(responseOperation.ReturnCode, result.ReturnCode);
        }

        [TestMethod]
        public void TurnLightGroupOffSucceeds()
        {
            var groupId = 1L;
            var group = new Group
            {
                GroupId = groupId,
                Name = "group1"
            };
            var responseOperation = new OperationResponse
            {
                ReturnCode = 0
            };


            Mock.Arrange(() => RestCallExecutor.Invoke(HttpMethod.Get, Arg.AnyString, Arg.IsAny<Dictionary<string, string>>(), ""))
                .IgnoreInstance()
                .Returns(responseOperation.SerializeObject)
                .OccursOnce();

            var result = Sut.TurnLightGroupOff(group);

            Mock.Assert(RestCallExecutor);
            Assert.IsNotNull(result);
            Assert.AreEqual(responseOperation.ReturnCode, result.ReturnCode);
        }
    }
}<commit_msg>Implemented tests for setting level<commit_after>﻿using System;
using System.Collections.Generic;
using biz.dfch.CS.Osram.Lightify.Client.Model;
using biz.dfch.CS.Web.Utilities.Rest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Telerik.JustMock;

namespace biz.dfch.CS.Osram.Lightify.Client.Tests
{
    [TestClass]
    public class ClientGroupOperationTest
    {
        public Client Sut;
        public RestCallExecutor RestCallExecutor;

        [TestInitialize]
        public void TestInitialize()
        {

            Sut = new Client(TestConstants.OSRAM_LIGHTIFY_BASE_URI)
            {
                UserInformation = new UserInformation()
                {
                    UserId = TestConstants.USER_ID,
                    Username = TestConstants.USERNAME,
                    Password = <PASSWORD>,
                    SerialNumber = TestConstants.SERIAL_NUMBER,
                    SecurityToken = TestConstants.SECURITY_TOKEN
                }
            };

            RestCallExecutor = Mock.Create<RestCallExecutor>();
        }

        [TestMethod]
        public void TurnLightGroupOnSucceeds()
        {
            var groupId = 1L;
            var group = new Group
            {
                GroupId = groupId,
                Name = "group1"
            };
            var responseOperation = new OperationResponse
            {
                ReturnCode = 0
            };


            Mock.Arrange(() => RestCallExecutor.Invoke(HttpMethod.Get, Arg.AnyString, Arg.IsAny<Dictionary<string, string>>(), ""))
                .IgnoreInstance()
                .Returns(responseOperation.SerializeObject)
                .OccursOnce();

            var result = Sut.TurnLightGroupOn(group);

            Mock.Assert(RestCallExecutor);
            Assert.IsNotNull(result);
            Assert.AreEqual(responseOperation.ReturnCode, result.ReturnCode);
        }

        [TestMethod]
        public void TurnLightGroupOffSucceeds()
        {
            var groupId = 1L;
            var group = new Group
            {
                GroupId = groupId,
                Name = "group1"
            };
            var responseOperation = new OperationResponse
            {
                ReturnCode = 0
            };


            Mock.Arrange(() => RestCallExecutor.Invoke(HttpMethod.Get, Arg.AnyString, Arg.IsAny<Dictionary<string, string>>(), ""))
                .IgnoreInstance()
                .Returns(responseOperation.SerializeObject)
                .OccursOnce();

            var result = Sut.TurnLightGroupOff(group);

            Mock.Assert(RestCallExecutor);
            Assert.IsNotNull(result);
            Assert.AreEqual(responseOperation.ReturnCode, result.ReturnCode);
        }

        public void SetLevelGroupSucceeds()
        {
            var groupId = 1L;
            var group = new Group
            {
                GroupId = groupId,
                Name = "group1"
            };
            var responseOperation = new OperationResponse
            {
                ReturnCode = 0
            };


            Mock.Arrange(() => RestCallExecutor.Invoke(HttpMethod.Get, Arg.AnyString, Arg.IsAny<Dictionary<string, string>>(), ""))
                .IgnoreInstance()
                .Returns(responseOperation.SerializeObject)
                .OccursOnce();

            var result = Sut.SetLevelGroup(group, 0.1);

            Mock.Assert(RestCallExecutor);
            Assert.IsNotNull(result);
            Assert.AreEqual(responseOperation.ReturnCode, result.ReturnCode);
        }

        public void SetLevelGroupWithTimeSucceeds()
        {
            var groupId = 1L;
            var group = new Group
            {
                GroupId = groupId,
                Name = "group1"
            };
            var responseOperation = new OperationResponse
            {
                ReturnCode = 0
            };


            Mock.Arrange(() => RestCallExecutor.Invoke(HttpMethod.Get, Arg.AnyString, Arg.IsAny<Dictionary<string, string>>(), ""))
                .IgnoreInstance()
                .Returns(responseOperation.SerializeObject)
                .OccursOnce();

            var result = Sut.SetLevelGroup(group, 0.1);

            Mock.Assert(RestCallExecutor);
            Assert.IsNotNull(result);
            Assert.AreEqual(responseOperation.ReturnCode, result.ReturnCode);
        }
    }
}
{'fraction_non_alphanumeric': 0.08816120906801007, 'fraction_numerical': 0.0030786453960257487, 'mean_word_length': 1.5885548714233972, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3957985', 'n_tokens_mistral': 1844, 'n_tokens_neox': 1742, 'n_words': 312}