Projekt

Obecné

Profil

« Předchozí | Další » 

Revize b11af9b1

Přidáno uživatelem Jakub Schenk před asi 2 roky(ů)

Testing cleanup + readme

cleaning testing, adding new comments to user creation frontend, adding readme

Zobrazit rozdíly:

Backend/BackendTesting/UserManagementTesting.cs
27 27
        private static readonly IConfiguration configuration = new ConfigurationBuilder().Build();
28 28
        public DatabaseContext ctx;
29 29
        public Core.Services.IUserService US;
30
        
30

  
31 31
        //constructor for creating database and filling it with dummy data
32 32
        public UserManagementTesting()
33 33
        {
......
87 87
            }
88 88

  
89 89
            //check for empty atributes
90
            if((username == null || username == "")&& output!=null)
90
            if ((username == null || username == "") && output != null)
91 91
            {
92 92
                Assert.Fail("user with no username created");
93 93
                return;
......
184 184
        {
185 185
            //new user creation
186 186
            User? newUser = US.CreateUser(oldUsername, oldName, oldSurname, password, oldRole);
187
            if(newUser == null)
187
            if (newUser == null)
188 188
            {
189 189
                Assert.Fail("user not created (maybe already user username?)");
190 190
            }
......
204 204
        [DataRow("bbb", "")]//set to none password
205 205
        [DataRow("eee", "eee")]//keep old password
206 206
        //test of changing password
207
        public void ChangePassword_Test(string username, string newPassword) 
207
        public void ChangePassword_Test(string username, string newPassword)
208 208
        {
209 209
            //get user using GetUserByUsername
210 210
            User? changingUser = US.GetUserByUsername(username);
211
            if(changingUser == null)
211
            if (changingUser == null)
212 212
            {
213 213
                Assert.Fail("user not found");
214 214
                return;
......
244 244

  
245 245
                Assert.AreNotEqual(oldPassword, renewedPassword, "password was not changed or it was changed on same value");
246 246
            }
247
            catch(Exception ex)
247
            catch (Exception ex)
248 248
            {
249
                if (newPassword == null || newPassword == "") Assert.IsTrue(true,"Try to change password on empty resulted in exception - expected and wanted outcome");
249
                if (newPassword == null || newPassword == "") Assert.IsTrue(true, "Try to change password on empty resulted in exception - expected and wanted outcome");
250 250
            }
251
            
251

  
252 252

  
253 253
        }
254 254
        [TestMethod]
......
259 259
        public void CheckUsernamePassword_Correct(string username, string password)
260 260
        {
261 261
            User? checkedUser = US.CheckUsernamePassword(username, password);
262
            if(checkedUser == null)
262
            if (checkedUser == null)
263 263
            {
264 264
                //there are just correct users - this should have returned user
265 265
                Assert.Fail("there are just correct users - this should have returned user");
266 266
                return;
267 267
            }
268 268
            User? expected = US.GetUserByUsername(username);
269
            if(expected == null)
269
            if (expected == null)
270 270
            {
271 271
                Assert.Fail("There is mistake in tested data");
272 272
                return;
......
299 299
        {
300 300
            //get user from database
301 301
            User? oldUser = US.CheckUsernamePassword(username, oldPassword);
302
            if (oldUser == null) 
302
            if (oldUser == null)
303 303
            {
304 304
                Assert.Fail("This should have returned user - there are wrong input data or CheckUsernamePassword isnt working properly");
305 305
                return;
......
314 314
            }
315 315
            //check if new password is in place
316 316
            User? newUser = US.CheckUsernamePassword(username, newPassword);
317
            if(newUser == null)
317
            if (newUser == null)
318 318
            {
319 319
                Assert.Fail("No user was returned - password probably wasnt changed");
320 320
            }
......
325 325

  
326 326
            //check if there is no way to login with old password
327 327
            User? oldPasswordTester = US.CheckUsernamePassword(username, oldPassword);
328
            if(oldPasswordTester != null)
328
            if (oldPasswordTester != null)
329 329
            {
330 330
                Assert.Fail("old password is still viable after password change");
331 331
            }

Také k dispozici: Unified diff