public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            PerformanceParameterName s = obj as PerformanceParameterName;

            if ((System.Object)s == null)
            {
                return(false);
            }

            if (this.id != s.id)
            {
                return(false);
            }
            if (this.name != s.name)
            {
                return(false);
            }

            return(true);
        }
        public void PerformanceParameterName_Initialization_Test()
        {
            try
            {
                // Arrange and Act
                PerformanceParameterName performanceParameterName = new PerformanceParameterName();

                // Assert
                Assert.IsNotNull(performanceParameterName);
            }
            catch (Exception)
            {
                throw new AssertFailedException("PerformanceParameterName initialization failed.");
            }
        }
Beispiel #3
0
        public PerformanceParameterName GetPerformanceParameterName(long performanceParameterNameId)
        {
            String                   sqlStr    = "SELECT id, name FROM perf_para_name WHERE id = " + performanceParameterNameId;
            MySqlCommand             cmd       = new MySqlCommand(sqlStr, conn);
            MySqlDataReader          sqlReader = cmd.ExecuteReader();
            PerformanceParameterName pp        = null;

            if (sqlReader.Read())
            {
                pp      = new PerformanceParameterName();
                pp.id   = sqlReader.GetInt32(0);
                pp.name = sqlReader.GetString(1);
            }

            sqlReader.Close();
            return(pp);
        }
        public void Repository_Get_PerformanceParameterName_Test()
        {
            try
            {
                // Arrange
                PerformanceParameterNameRepository performanceParameterNameRepository = new PerformanceParameterNameRepository();

                // Act
                PerformanceParameterName performanceParameterNameFromDb = performanceParameterNameRepository.GetPerformanceParameterName(1);

                // Assert
                Assert.IsNotNull(performanceParameterNameFromDb);
            }
            catch (Exception)
            {
                throw new AssertFailedException("Unable to fetch performance parameter name.");
            }
        }
Beispiel #5
0
        public ArrayList GetPerformanceParameterNames()
        {
            String                   sqlStr    = "SELECT * FROM perf_para_name";
            MySqlCommand             cmd       = new MySqlCommand(sqlStr, conn);
            MySqlDataReader          sqlReader = cmd.ExecuteReader();
            ArrayList                performanceParameterNames = new ArrayList();
            PerformanceParameterName pp = null;

            while (sqlReader.Read())
            {
                pp      = new PerformanceParameterName();
                pp.id   = sqlReader.GetInt32(0);
                pp.name = sqlReader.GetString(1);
                performanceParameterNames.Add(pp);
            }

            sqlReader.Close();
            return(performanceParameterNames);
        }
        public void PerformanceParameterName_Property_Set_Test()
        {
            try
            {
                // Arrange
                PerformanceParameterName performanceParameterName = new PerformanceParameterName();

                // Act
                performanceParameterName.id   = 1;
                performanceParameterName.name = "parameterName";

                // Assert
                Assert.AreEqual <long>(performanceParameterName.id, 1);
                Assert.AreEqual <string>(performanceParameterName.name, "parameterName");
            }
            catch (Exception)
            {
                throw new AssertFailedException("Setting PerformanceParameterName properties failed.");
            }
        }
        public void Get_All_PerformanceParameterNames_Test()
        {
            // Arrange
            ArrayList performanceParameterNamesObjsAsOuptut = new ArrayList();

            PerformanceParameterName performanceParameterNameObj1AsOutput = new PerformanceParameterName();

            performanceParameterNameObj1AsOutput.id   = 1;
            performanceParameterNameObj1AsOutput.name = "Para Name 1";

            PerformanceParameterName performanceParameterNameObj2AsOutput = new PerformanceParameterName();

            performanceParameterNameObj2AsOutput.id   = 2;
            performanceParameterNameObj2AsOutput.name = "Para Name 2";

            performanceParameterNamesObjsAsOuptut.Add(performanceParameterNameObj1AsOutput);
            performanceParameterNamesObjsAsOuptut.Add(performanceParameterNameObj2AsOutput);

            var mockRepository = new Mock <IPerformanceParameterNameRepository>();

            mockRepository.Setup(x => x.GetPerformanceParameterNames())
            .Returns(performanceParameterNamesObjsAsOuptut);

            var controller = new PerformanceParameterNameController(mockRepository.Object);

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();

            // Act
            ArrayList performanceParameterNamesObj = controller.Get();

            // Assert
            Assert.AreEqual <int>(performanceParameterNamesObj.Count, performanceParameterNamesObjsAsOuptut.Count);
            Assert.AreEqual(performanceParameterNamesObj[0], performanceParameterNamesObjsAsOuptut[0]);
            Assert.AreEqual(performanceParameterNamesObj[1], performanceParameterNamesObjsAsOuptut[1]);
        }