PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/src/AddIns/Misc/PackageManagement/Test/Src/PackageViewModelOperationLoggerTests.cs

https://github.com/ajadex/SharpDevelop
C# | 64 lines | 38 code | 9 blank | 17 comment | 0 complexity | 3fb5ba0e5800a9a6aaef7e9dc6986470 MD5 | raw file
 1// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
 2// 
 3// Permission is hereby granted, free of charge, to any person obtaining a copy of this
 4// software and associated documentation files (the "Software"), to deal in the Software
 5// without restriction, including without limitation the rights to use, copy, modify, merge,
 6// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
 7// to whom the Software is furnished to do so, subject to the following conditions:
 8// 
 9// The above copyright notice and this permission notice shall be included in all copies or
10// substantial portions of the Software.
11// 
12// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17// DEALINGS IN THE SOFTWARE.
18
19using System;
20using ICSharpCode.PackageManagement;
21using NuGet;
22using NUnit.Framework;
23using Rhino.Mocks;
24
25namespace PackageManagement.Tests
26{
27	[TestFixture]
28	public class PackageViewModelOperationLoggerTests
29	{
30		PackageViewModelOperationLogger operationLogger;
31		IPackage fakePackage;
32		ILogger fakeLogger;
33		
34		void CreateLogger()
35		{
36			fakePackage = MockRepository.GenerateStub<IPackage>();
37			fakeLogger = MockRepository.GenerateStub<ILogger>();
38			operationLogger = new PackageViewModelOperationLogger(fakeLogger, fakePackage);
39		}
40		
41		[Test]
42		public void ResolveFileConflict_MessagePassed_MessagePassedToWrappedLogger()
43		{
44			CreateLogger();
45			
46			FileConflictResolution resolution = operationLogger.ResolveFileConflict("message");
47			
48			fakeLogger.AssertWasCalled(logger => logger.ResolveFileConflict("message"));
49		}
50		
51		[Test]
52		public void ResolveFileConflict_WrappedLoggerResolveFileConflictReturnsOverwriteAll_ReturnsOverwriteAll()
53		{
54			CreateLogger();
55			fakeLogger
56				.Stub(logger => logger.ResolveFileConflict("message"))
57				.Return(FileConflictResolution.OverwriteAll);
58			
59			FileConflictResolution resolution = operationLogger.ResolveFileConflict("message");
60			
61			Assert.AreEqual(FileConflictResolution.OverwriteAll, resolution);
62		}
63	}
64}