forked from zachtaylor1/SWProj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerTests.cs
More file actions
85 lines (82 loc) · 1.86 KB
/
ServerTests.cs
File metadata and controls
85 lines (82 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SWProjv1;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
namespace SWProjv1.Tests
{
[TestClass()]
public class ServerTests
{
[TestMethod()]
public void InitTest()
{
try
{
Server.Init();
Server.Init();
Server.Init();
Server.Init();
Server.Init();
Server.Init();
Server.Init();
}
catch (Exception e)
{
Assert.Fail(e.Message);
}
}
[TestMethod()]
public void LogInQueryTest()
{
int x;
x=Server.LogInQuery("A", "B");
Assert.AreEqual(x, -1);
x = Server.LogInQuery("AdMiN", "ADmiNPasSS");
Assert.AreEqual(x, -1);
x = Server.LogInQuery("student2", "iamstudent");
Assert.AreEqual(x, 1);
x =Server.LogInQuery("admin", "adminpass");
Assert.AreEqual(x, 2);
x =Server.LogInQuery("ra1", "rapass");
Assert.AreEqual(x, 3);
}
[TestMethod()]
public void Emptyrun_queryTest()
{
try
{
var x = Server.run_query("");
Assert.Fail();
}
catch(Exception e)
{
}
}
public void Wrongrun_queryTest()
{
try
{
var x = Server.run_query("SELECT FROM User_T WHERE UserID = '3'");
Assert.Fail();
}
catch (Exception e)
{
}
}
public void Correctrun_queryTest()
{
try
{
var x = Server.run_query("SELECT * FROM User_T WHERE UserID = '3'");
}
catch (Exception e)
{
Assert.Fail(e.Message);
}
}
}
}