moq/moq4: Repo for managing Moq 4.x - GitHub

文章推薦指數: 80 %
投票人數:10人

Moq (pronounced "Mock-you" or just "Mock") is the only mocking library for .NET developed from scratch to take full advantage of .NET Linq expression trees and ... Skiptocontent {{message}} moq / moq4 Public Notifications Fork 653 Star 4.8k RepoformanagingMoq4.x moq.github.io/moq4 License Viewlicense 4.8k stars 653 forks Star Notifications Code Issues 28 Pullrequests 7 Actions Wiki Security Insights More Code Issues Pullrequests Actions Wiki Security Insights moq/moq4 Thiscommitdoesnotbelongtoanybranchonthisrepository,andmaybelongtoaforkoutsideoftherepository. main Branches Tags Couldnotloadbranches Nothingtoshow {{refName}} default Couldnotloadtags Nothingtoshow {{refName}} default 3 branches 100 tags Code Clone HTTPS GitHubCLI UseGitorcheckoutwithSVNusingthewebURL. WorkfastwithourofficialCLI. Learnmore. OpenwithGitHubDesktop DownloadZIP LaunchingGitHubDesktop Ifnothinghappens,downloadGitHubDesktopandtryagain. LaunchingGitHubDesktop Ifnothinghappens,downloadGitHubDesktopandtryagain. LaunchingXcode Ifnothinghappens,downloadXcodeandtryagain. LaunchingVisualStudioCode Yourcodespacewillopenonceready. Therewasaproblempreparingyourcodespace,pleasetryagain. Latestcommit kzu Removeolderunmonitoredgitterchat … 27e97cb Aug18,2022 Removeolderunmonitoredgitterchat 27e97cb Gitstats 2,268 commits Files Permalink Failedtoloadlatestcommitinformation. Type Name Latestcommitmessage Committime .github Fixincludeworkflow Aug18,2022 build Don'tupdateAppVeyorbuildnumber Feb27,2021 docs CreatebasicsetupforJekyll-basedwebsite(#1208) Aug28,2021 src/Moq LetStubbedPropertiesSetupfigureouttypeparaminalessfragileway Aug5,2022 tests AddfailingtestforSetupAllPropertiescalledonMock<>subclass Aug5,2022 .editorconfig Fix.editorconfigforauto-generatedfiles Aug17,2019 .gitattributes AddedCRLFsettingstorepo Jul8,2013 .gitignore Don'tignoretop-leveldot-folders Aug5,2022 .netconfig Bumpdependencieswithdotnet-file-sync Aug18,2022 Before.Moq.sln.targets Simplifythebuildprocess&scripts(#648) Jul27,2018 CHANGELOG.md Updatechangelog Aug5,2022 CONTRIBUTING.md Forgottoreplacemasterbranchnameinafewplaces Feb27,2021 Directory.Build.props Don'tfailinitialrestorewhenopeningdirectlyinVS Dec13,2018 GitInfo.txt Finalpolishforversion4.18.2 Aug2,2022 License.txt Includecontributorsincopyrightnotice Jun27,2020 Moq.sln Removenon-existentsolutionitemMoq.nuspec Aug8,2019 Moq.snk Mergedbranchfordynamictypes. Jan3,2008 README.md Removeolderunmonitoredgitterchat Aug18,2022 appveyor.yml CIbuildshoulduseVS2022 May11,2022 moq-bigger.png UpdatedtousenugetpackagesforCastleandxUnitdependencies,asw… Aug21,2013 moq-icon.png AddNuGetpackageicon Oct22,2020 moq-small.png cleanedupAsMockExtensions Aug9,2009 moq.png tentativelogo Aug24,2008 Viewcode moq What? Why? Where? Who? Featuresataglance Sponsors README.md moq Themostpopularandfriendlymockinglibraryfor.NET varmock=newMock(); //WOW!Norecord/replayweirdness?!:) mock.Setup(library=>library.DownloadExists("2.0.0.0")) .Returns(true); //UsetheObjectpropertyonthemocktogetareferencetotheobject //implementingILoveThisLibrary,andthenexerciseitbycalling //methodsonit ILoveThisLibrarylovable=mock.Object; booldownload=lovable.DownloadExists("2.0.0.0"); //Verifythatthegivenmethodwasindeedcalledwiththeexpectedvalueatmostonce mock.Verify(library=>library.DownloadExists("2.0.0.0"),Times.AtMostOnce()); MoqalsoisthefirstandonlylibrarysofartoprovideLinqtoMocks,sothatthesamebehaviorabovecanbeachievedmuchmoresuccinctly: ILoveThisLibrarylovable=Mock.Of(l=> l.DownloadExists("2.0.0.0")==true); //ExercisetheinstancereturnedbyMock.Ofbycallingmethodsonit... booldownload=lovable.DownloadExists("2.0.0.0"); //Simplyassertthereturnedstate: Assert.True(download); //Ifyouwanttogobeyondstatetestingandwantto //verifythemockinteractioninstead... Mock.Get(lovable).Verify(library=>library.DownloadExists("2.0.0.0")); YoucanthinkofLinqtoMocksas"fromtheuniverseofmocks,givemeonewhosebehaviormatchesthisexpression". CheckouttheQuickstartformoreexamples! What? Moq(pronounced"Mock-you"orjust"Mock")istheonlymockinglibraryfor.NETdevelopedfromscratchtotakefulladvantageof.NETLinqexpressiontreesandlambdaexpressions,whichmakesitthemostproductive,type-safeandrefactoring-friendlymockinglibraryavailable.Anditsupportsmockinginterfacesaswellasclasses.ItsAPIisextremelysimpleandstraightforward,anddoesn'trequireanypriorknowledgeorexperiencewithmockingconcepts. Why? Thelibrarywascreatedmainlyfordeveloperswhoaren'tcurrentlyusinganymockinglibrary(oraredispleasedwiththecomplexitiesofsomeotherimplementation),andwhoaretypicallymanuallywritingtheirownmocks(withmoreorless"fanciness").Mostdevelopersinthissituationalsohappentobequitepragmaticandadheretostate(orclassic)TDD.It'stheresultoffeelingthatthebarrierofentryfromothermockinglibrariesisabithigh,andasimpler,morelightweightandelegantapproachispossible.MoqachievesallthisbytakingfulladvantageoftheelegantandcompactC#andVBlanguagefeaturescollectivelyknownasLINQ(theyarenotjustforqueries,astheacronymimplies). Moqisdesignedtobeaverypractical,unobtrusiveandstraight-forwardwaytoquicklysetupdependenciesforyourtests.ItsAPIdesignhelpsevennoviceuserstofallinthe"pitofsuccess"andavoidmostcommonmisuses/abusesofmocking. Whenitwasconceived,itwastheonlymockinglibrarythatwentagainstthegeneralizedandsomewhatunintuitive(especiallyfornovices)Record/Replayapproachfromallotherlibraries(andthatmighthavebeenagoodthing;)). NotusingRecord/Replayalsomeansthatit'sstraightforwardtomovecommonexpectationstoafixturesetupmethodandevenoverridethoseexpectationswhenneededinaspecificunittest. Youcanreadmoreaboutthe"why"andseesomenicescreenshotsatkzu'sblog. Where? SeeourQuickstartexamplestogetafeelingoftheextremelysimpleAPIandinstallfromNuGet. Readabouttheannouncementatkzu'sblog.GetsomebackgroundonthestateofmocklibrariesfromScottHanselman. In-depthdocumentationisbeingaddedtothedocumentationwebsite. Who? MoqwasoriginallydevelopedbyClarius,ManasandInSTEDD. MoqusesCastleDynamicProxyinternallyastheinterceptionmechanismtoenablemocking. Featuresataglance Moqoffersthefollowingfeatures: Strong-typed:nostringsforexpectations,noobject-typedreturnvaluesorconstraints UnsurpassedVSIntelliSenseintegration:everythingsupportsfullVSIntelliSense,fromsettingexpectations,tospecifyingmethodcallarguments,returnvalues,etc. NoRecord/Replayidiomstolearn.Justconstructyourmock,setitup,useitandoptionallyverifycallstoit(youmaynotverifymockswhentheyactasstubsonly,orwhenyouaredoingmoreclassicstate-basedtestingbycheckingreturnedvaluesfromtheobjectundertest) VERYlowlearningcurveasaconsequenceofthepreviousthreepoints.Forthemostpart,youdon'tevenneedtoeverreadthedocumentation. GranularcontrolovermockbehaviorwithasimpleMockBehaviorenumeration(noneedtolearnwhat'sthetheoreticaldifferencebetweenamock,astub,afake,adynamicmock,etc.) Mockbothinterfacesandclasses Overrideexpectations:cansetdefaultexpectationsinafixturesetup,andoverrideasneededontests Passconstructorargumentsformockedclasses Interceptandraiseeventsonmocks Intuitivesupportforout/refarguments Weappreciatedeeplyanyfeedbackthatyoumayhave!Feelfreetoparticipateinthechat,orreportanissueintheissuetracker. Sponsors Specialthankstothefollowinggoldsponsorsofthisproject: Andtoalloursponsors! getmentionedheretoo! About RepoformanagingMoq4.x moq.github.io/moq4 Resources Readme License Viewlicense Stars 4.8k stars Watchers 186 watching Forks 653 forks Releases 100 tags Sponsorthisproject   Sponsor LearnmoreaboutGitHubSponsors Usedby142k +142,214 Contributors93 +82contributors Languages C# 99.5% Other 0.5% Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.



請為這篇文章評分?