public void CreateQueryParameter_Test() { // Arrange int queryParametersCountBeforeAct = queryParametersDbSet.Count(); int lastQueryParameterIdInDbSetBeforeAct = queryParametersDbSet .Last() .SqlQueryParameterId; int queryParameterId = 12; int parameterId = 12; int queryId = 12; SqlQueryParameter queryParameterToCreate = new SqlQueryParameter() { SqlQueryParameterId = queryParameterId, ParameterId = parameterId, SqlQueryId = queryId }; // Act queryParamRepo.Create(queryParameterToCreate); SqlQueryParameter createdQueryParam = queryParametersDbSet.Last(); // Assert Assert.IsTrue(queryParametersDbSet.Count() > queryParametersCountBeforeAct); Assert.AreNotEqual( lastQueryParameterIdInDbSetBeforeAct, createdQueryParam.SqlQueryParameterId ); Assert.AreEqual(queryParameterId, createdQueryParam.SqlQueryParameterId); Assert.AreEqual(parameterId, createdQueryParam.ParameterId); Assert.AreEqual(queryId, createdQueryParam.SqlQueryId); }
public void GetAllQueries() { // Act IEnumerable <SqlQuery> queries = queryRepo.GetAll(); // Assert Assert.AreEqual(queriesDbSet.Count(), queries.Count()); Assert.AreEqual( queriesDbSet.First(), queries.First() ); Assert.AreEqual( queriesDbSet.Last(), queries.Last() ); Assert.AreEqual( queriesDbSet.First().SqlQueryName, queries.First().SqlQueryName ); }
public void CreateParameter() { // Arrange int ElementsCountBeforeAct = parametersDbSet.Count(); Parameter parameter = new Parameter() { ParameterName = "@added", ParameterRuName = "added", ParameterCreatedDate = DateTime.Now }; // Act repository.Create(parameter); // Assert Assert.AreNotEqual(ElementsCountBeforeAct, parametersDbSet.Count()); Assert.IsTrue(parametersDbSet.Count() > ElementsCountBeforeAct); Assert.AreEqual("@added", parametersDbSet.Last().ParameterName); }
public void CreateQueryWithTwoParams_WhenSecondParameterIsNotNull() { // Arrange int queryElementsCountBeforeAct = queriesDbSet.Count(); int queryParametersElementsCountBeforeAct = queryParametersDbSet.Count(); int parametersElementsCountBeforeAct = parametersDbSet.Count(); string createQueryName = "New query"; string createQueryContent = "string type"; int firstQueryParameterId = parametersElementsCountBeforeAct + 1; string firstQueryParameterName = "CreatedQueryFirstParameterName"; string firstQueryParameterRuName = "первый параметр запроса"; string firstQueryParameterType = "text"; int secondQueryParameterId = firstQueryParameterId + 1; string secondQueryParameterName = "CreateQuerySecondParameterName"; string secondQueryParameterRuName = "второй параметр запроса"; string secondQueryParameterType = "phone"; SqlQuery queryToCreate = new SqlQuery() { SqlQueryId = queryElementsCountBeforeAct + 1, SqlQueryName = createQueryName, SqlQueryContent = createQueryContent, SqlQueryCreatedDate = DateTime.Now }; Parameter firstParameter = new Parameter() { ParameterId = firstQueryParameterId, ParameterName = firstQueryParameterName, ParameterRuName = firstQueryParameterRuName, ParameterType = firstQueryParameterType }; parametersDbSet.Add(firstParameter); Parameter secondParameter = new Parameter() { ParameterId = secondQueryParameterId, ParameterName = secondQueryParameterName, ParameterRuName = secondQueryParameterRuName, ParameterType = secondQueryParameterType }; parametersDbSet.Add(secondParameter); string[] parameterIds = new string[] { firstParameter.ParameterId.ToString(), secondParameter.ParameterId.ToString() }; // Act queryRepo.Create(queryToCreate, parameterIds); SqlQuery createdQuery = queriesDbSet.Last(); int lastQueryParameterId = queryParametersDbSet.Last().SqlQueryParameterId; SqlQueryParameter[] twoLastQueryParameters = new SqlQueryParameter[] { queryParametersDbSet.Last(), queryParametersDbSet.ToList()[queryParametersDbSet.Count() - 2] }; // Assert Assert.IsTrue(queriesDbSet.Count() > queryElementsCountBeforeAct); Assert.IsTrue(parametersDbSet.Count() > parametersElementsCountBeforeAct); Assert.IsTrue(queryParametersDbSet.Count() > queryParametersElementsCountBeforeAct); foreach (SqlQueryParameter queryParameter in twoLastQueryParameters) { Assert.IsTrue(queryParameter.SqlQueryId == createdQuery.SqlQueryId); Assert.IsTrue( queryParameter.ParameterId == firstQueryParameterId || queryParameter.ParameterId == secondQueryParameterId ); } }
public void GetAllOutputTables_Test() { // Arrange int tablesCount = tablesDbSet.Count(); // Act IEnumerable <OutputTable> tables = outRepo.GetAll(); // Assert Assert.AreEqual(tablesCount, tables.Count()); Assert.AreEqual(tablesCount, tablesDbSet.Count()); Assert.AreEqual(tables.First().OutputTableId, tablesDbSet.First().OutputTableId); Assert.AreEqual(tables.Last().FileName, tablesDbSet.Last().FileName); }