Skip to content

Commit 091b295

Browse files
committed
Some code improvements have been done by the advices from JetBrains Rider
1 parent 9353270 commit 091b295

File tree

8 files changed

+30
-28
lines changed

8 files changed

+30
-28
lines changed
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Microsoft.AspNetCore.Mvc;
21
using Microsoft.Extensions.Configuration;
32
using Moq;
43
using WeatherStackNetCore.Controllers;
@@ -8,45 +7,47 @@ namespace WeatherStackNetCore.Tests.Controllers;
87

98
public class AutoCompleteControllerTests
109
{
11-
private AutoCompleteViewModel _model;
12-
private IConfiguration _config;
13-
private Mock _mock;
14-
private AutoCompleteController _controller;
10+
private AutoCompleteViewModel? _model;
11+
private IConfiguration? _config;
12+
private Mock? _mock;
13+
private AutoCompleteController? _controller;
1514

1615
[SetUp]
1716
public void Setup()
1817
{
19-
_model = new AutoCompleteViewModel();
20-
_model.PlaceName = "Ankara";
18+
_model = new AutoCompleteViewModel
19+
{
20+
PlaceName = "Ankara"
21+
};
2122
_config = new ConfigurationManager();
2223
_controller = new AutoCompleteController(_config);
2324
}
2425

2526
[Test]
2627
public void IndexWithModel_Test()
2728
{
28-
var result = _controller.IndexWithModel(_model);
29-
Assert.IsNotNull(result);
29+
var result = _controller?.IndexWithModel(_model);
30+
Assert.That(result, Is.Not.Null);
3031
}
3132

3233
[Test]
3334
public void GetLocationsWithModel_Test()
3435
{
35-
var result = _controller.GetLocationsWithModel(_model);
36-
Assert.IsNotNull(result);
36+
var result = _controller?.GetLocationsWithModel(_model);
37+
Assert.That(result, Is.Not.Null);
3738
}
3839

3940
[Test]
4041
public void IndexWithJQuery_Test()
4142
{
42-
var result = _controller.IndexWithJQuery();
43-
Assert.IsNotNull(result);
43+
var result = _controller?.IndexWithJQuery();
44+
Assert.That(result, Is.Not.Null);
4445
}
4546

4647
[Test]
4748
public void GetLocationsWithJQuery_Test()
4849
{
49-
var result = _controller.GetLocations(_model.PlaceName);
50+
var result = _controller?.GetLocations(_model.PlaceName);
5051
Assert.AreSame(result.Exception, null);
5152
}
5253
}
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Microsoft.AspNetCore.Mvc;
21
using Microsoft.Extensions.Configuration;
32
using Moq;
43
using WeatherStackNetCore.Controllers;
@@ -8,45 +7,47 @@ namespace WeatherStackNetCore.Tests.Controllers;
87

98
public class CurrentWeatherControllerTests
109
{
11-
private CurrentWeatherViewModel _model;
12-
private IConfiguration _config;
13-
private Mock _mock;
14-
private CurrentWeatherController _controller;
10+
private CurrentWeatherViewModel? _model;
11+
private IConfiguration? _config;
12+
private Mock? _mock;
13+
private CurrentWeatherController? _controller;
1514

1615
[SetUp]
1716
public void Setup()
1817
{
19-
_model = new CurrentWeatherViewModel();
20-
_model.PlaceName = "Konya";
18+
_model = new CurrentWeatherViewModel
19+
{
20+
PlaceName = "Konya"
21+
};
2122
_config = new ConfigurationManager();
2223
_controller = new CurrentWeatherController(_config);
2324
}
2425

2526
[Test]
2627
public void IndexWithModel_Test()
2728
{
28-
var result = _controller.IndexWithModel(_model);
29-
Assert.IsNotNull(result);
29+
var result = _controller?.IndexWithModel(_model);
30+
Assert.That(result, Is.Not.Null);
3031
}
3132

3233
[Test]
3334
public void GetCurrentWeatherWithModel_Test()
3435
{
35-
var result = _controller.GetCurrentWeatherWithModel(_model);
36-
Assert.IsNotNull(result);
36+
var result = _controller?.GetCurrentWeatherWithModel(_model);
37+
Assert.That(result, Is.Not.Null);
3738
}
3839

3940
[Test]
4041
public void IndexWithJQuery_Test()
4142
{
42-
var result = _controller.IndexWithJQuery();
43-
Assert.IsNotNull(result);
43+
var result = _controller?.IndexWithJQuery();
44+
Assert.That(result, Is.Not.Null);
4445
}
4546

4647
[Test]
4748
public void GetCurrentWeatherWithJQuery_Test()
4849
{
49-
var result = _controller.GetCurrentWeather(_model.PlaceName, _model.Unit, _model.Language);
50+
var result = _controller?.GetCurrentWeather(_model.PlaceName, _model.Unit, _model.Language);
5051
Assert.AreSame(result.Exception, null);
5152
}
5253
}
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)